tkinter question
Eric_Dexter at msn.com
Eric_Dexter at msn.com
Mon Dec 1 03:41:40 EST 2008
On Oct 26, 7:02 am, "Chuckk Hubbard" <badmuthahubb... at gmail.com>
wrote:
> Hello.
> How about this? I changed the if statements so the coordinates are
> always updated, but only changed if within the right limits, otherwise
> updated to the existing value. Now if you drag outside the limits of
> one dimension, it still moves in the other dimension. Not sure if
> that's what you want. I'm amazed that this can be so simple, I came
> up with an intricate system for my app, not realizing I could bind
> events to canvas items!
> BTW, I've never come across csoundroutines, can you give me a synopsis
> of what it's for? I'm using thePythonCsoundAPI. This is why I
> commented out all the references to csoundroutines, I don't have it
> installed at the moment.
> -Chuckk
>
> #!/usr/bin/python
> from Tkinter import *
> #import csoundroutines as cs
>
> root = Tk()
>
> global canv
> xx = {}
>
> def makeFrame(root):
> global canv
> # test = cs.csdInstrumentlist3('bay-at-night.csd')
> canv = Canvas (root, height = 200, width = 350)
>
> # for i in range (0, len(test.instr_number)):
> for i in range (0, 4):
> # canv.create_text(10, i *10, text=str(test.instr_number[i]) +
> canv.create_text(10, i *10, text=str(i) +
> '...', tags=('movable'))
> xx[i] = canv.tag_bind('movable', '<B1-Motion>', slide) #B1-motion
> is a drag with left button down
> canv.pack()
>
> def slide (event):
> '''
> triggered when something is dragged on the canvas - move thing
> under
> mouse ('current') to new position
> '''
> if 0 < event.x < 200:
> newx = event.x
> else: newx = canv.coords('current')[0]
> if 0 < event.y < 100:
> newy = event.y
> else: newy = canv.coords('current')[1]
> canv.coords('current', newx, newy)
>
> makeFrame(root)
> root.mainloop()
>
>
>
>
>
> On Fri, Oct 3, 2008 at 3:44 PM, Eric_Dex... at msn.com <Eric_Dex... at msn.com> wrote:
> > I saw this (close to this anyway) lieing around on the internet and
> > was wanting to use it to define a start point exc but I need the
> > graphics to stay within a set y coords and I am not realy sure how to
> > do that. I have no idea on how to bind a min/max y to it. (the
> > concept is inspired by the javacsoundblue).
>
> > #!/usr/bin/python
> > from Tkinter import *
> > import csoundroutines as cs
>
> > root = Tk()
>
> > global canv
> > xx = {}
>
> > def makeFrame(root):
> > global canv
> > test = cs.csdInstrumentlist3('bay-at-night.csd')
> > canv = Canvas (root, height = 200, width = 350)
>
> > for i in range (0, len(test.instr_number)):
> > canv.create_text(10, i *10, text=str(test.instr_number[i]) +
> > '...', tags=('movable'))
> > xx[i] = canv.tag_bind('movable', '<B1-Motion>', slide) #B1-motion
> > is a drag with left button down
> > canv.pack()
>
> > def slide (event):
> > '''
> > triggered when something is dragged on the canvas - move thing
> > under
> > mouse ('current') to new position
> > '''
> > newx = event.x
> > if event.y < 10 and event.y > 0:
> > newy = event.y
> > canv.coords('current', newx, newy)
>
> > makeFrame(root)
> > root.mainloop()
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> --http://www.badmuthahubbard.com- Hide quoted text -
>
> - Show quoted text -
haven't tried this yet but I look foward to trying it out..
More information about the Python-list
mailing list