tkinter question

Eric_Dexter at msn.com Eric_Dexter at msn.com
Fri Oct 3 09:44:08 EDT 2008


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 java csound blue).


#!/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()



More information about the Python-list mailing list