[Tutor] Bindings in Tkinter
shendric@arches.uga.edu
shendric@arches.uga.edu
Wed, 29 May 2002 10:56:24 -0500
Hello,
I'm having difficulty with bindings, but I'm not real sure what I'm
doing wrong. The following is a small bit of code that is part of a
larger app that I'm working on. The idea is to simply bind the
<Control-Shift-Up> key to a little printing function, but it does
nothing at all.
The larger app actually contains things within the frames that are
created, but I left them out of this for convenience and brevity.
Any ideas?
Sean Hendricks
from Tkinter import *
import Pmw
class VTrans:
def __init__(self, master):
self.master = master
self.frame = Frame(master)
self.frame.top = Frame(master)
self.frame.bottom = Frame(master)
self.frame.top.pack(side=TOP, fill=X)
self.frame.bottom.pack(side=TOP)
self.frame.pack()
self.getBindings()
def doStuff(self, event=None):
print "I am the very model of a ..."
def getBindings(self):
self.frame.top.bind('<Control-Shift-Up>', self.doStuff)
if __name__ == "__main__":
root = Tk()
root.title('Test')
Pmw.initialise()
main = VTrans(root)
root.mainloop()