PATH:
usr
/
lib64
/
python2.7
/
Demo
/
tkinter
/
matt
from Tkinter import * class Test(Frame): def printit(self): print "hi" def createWidgets(self): self.QUIT = Button(self, text='QUIT', background='red', foreground='white', height=3, command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.canvasObject = Canvas(self, width="5i", height="5i") self.canvasObject.pack(side=LEFT) def mouseDown(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object self.startx = self.canvasObject.canvasx(event.x) self.starty = self.canvasObject.canvasy(event.y) def mouseMotion(self, event): # canvas x and y take the screen coords from the event and translate # them into the coordinate system of the canvas object x = self.canvasObject.canvasx(event.x) y = self.canvasObject.canvasy(event.y) if (self.startx != event.x) and (self.starty != event.y) : self.canvasObject.delete(self.rubberbandBox) self.rubberbandBox = self.canvasObject.create_rectangle( self.startx, self.starty, x, y) # this flushes the output, making sure that # the rectangle makes it to the screen # before the next event is handled self.update_idletasks() def mouseUp(self, event): self.canvasObject.delete(self.rubberbandBox) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() # this is a "tagOrId" for the rectangle we draw on the canvas self.rubberbandBox = None # and the bindings that make it work.. Widget.bind(self.canvasObject, "<Button-1>", self.mouseDown) Widget.bind(self.canvasObject, "<Button1-Motion>", self.mouseMotion) Widget.bind(self.canvasObject, "<Button1-ButtonRelease>", self.mouseUp) test = Test() test.mainloop()
[-] canvas-gridding.py
[edit]
[-] radiobutton-simple.py
[edit]
[-] canvas-gridding.pyc
[edit]
[-] two-radio-groups.pyo
[edit]
[-] rubber-band-box-demo-1.py
[edit]
[-] rubber-line-demo-1.py
[edit]
[-] canvas-moving-or-creating.pyo
[edit]
[-] 00-HELLO-WORLD.py
[edit]
[-] window-creation-w-location.pyc
[edit]
[-] canvas-moving-w-mouse.py
[edit]
[-] animation-simple.py
[edit]
[-] canvas-moving-w-mouse.pyc
[edit]
[-] canvas-moving-w-mouse.pyo
[edit]
[-] animation-w-velocity-ctrl.py
[edit]
[+]
..
[-] canvas-demo-simple.pyc
[edit]
[-] not-what-you-might-think-2.pyc
[edit]
[-] packer-simple.pyc
[edit]
[-] two-radio-groups.py
[edit]
[-] rubber-line-demo-1.pyc
[edit]
[-] menu-all-types-of-entries.py
[edit]
[-] killing-window-w-wm.pyc
[edit]
[-] README
[edit]
[-] canvas-moving-or-creating.pyc
[edit]
[-] animation-simple.pyo
[edit]
[-] packer-and-placer-together.py
[edit]
[-] animation-w-velocity-ctrl.pyc
[edit]
[-] pong-demo-1.pyc
[edit]
[-] rubber-band-box-demo-1.pyc
[edit]
[-] two-radio-groups.pyc
[edit]
[-] menu-all-types-of-entries.pyc
[edit]
[-] slider-demo-1.py
[edit]
[-] packer-simple.py
[edit]
[-] printing-coords-of-items.pyo
[edit]
[-] dialog-box.pyo
[edit]
[-] entry-simple.pyo
[edit]
[-] subclass-existing-widgets.pyc
[edit]
[-] window-creation-more.pyc
[edit]
[-] dialog-box.pyc
[edit]
[-] not-what-you-might-think-1.pyc
[edit]
[-] radiobutton-simple.pyo
[edit]
[-] canvas-moving-or-creating.py
[edit]
[-] placer-simple.pyc
[edit]
[-] menu-simple.pyo
[edit]
[-] rubber-band-box-demo-1.pyo
[edit]
[-] canvas-gridding.pyo
[edit]
[-] placer-simple.py
[edit]
[-] animation-w-velocity-ctrl.pyo
[edit]
[-] canvas-reading-tag-info.pyo
[edit]
[-] canvas-with-scrollbars.pyc
[edit]
[-] killing-window-w-wm.py
[edit]
[-] window-creation-w-location.py
[edit]
[-] not-what-you-might-think-2.pyo
[edit]
[-] entry-simple.pyc
[edit]
[-] entry-simple.py
[edit]
[-] rubber-line-demo-1.pyo
[edit]
[-] subclass-existing-widgets.pyo
[edit]
[-] window-creation-simple.pyo
[edit]
[-] canvas-mult-item-sel.pyo
[edit]
[-] window-creation-simple.pyc
[edit]
[-] canvas-w-widget-draw-el.pyc
[edit]
[-] canvas-with-scrollbars.pyo
[edit]
[-] window-creation-more.pyo
[edit]
[-] canvas-mult-item-sel.pyc
[edit]
[-] canvas-reading-tag-info.pyc
[edit]
[-] killing-window-w-wm.pyo
[edit]
[-] bind-w-mult-calls-p-type.pyo
[edit]
[-] entry-with-shared-variable.py
[edit]
[-] 00-HELLO-WORLD.pyc
[edit]
[-] canvas-with-scrollbars.py
[edit]
[-] pong-demo-1.pyo
[edit]
[-] window-creation-more.py
[edit]
[-] slider-demo-1.pyc
[edit]
[-] menu-simple.py
[edit]
[-] animation-simple.pyc
[edit]
[-] subclass-existing-widgets.py
[edit]
[-] canvas-w-widget-draw-el.pyo
[edit]
[-] packer-and-placer-together.pyc
[edit]
[-] bind-w-mult-calls-p-type.pyc
[edit]
[-] not-what-you-might-think-1.py
[edit]
[-] not-what-you-might-think-2.py
[edit]
[-] window-creation-simple.py
[edit]
[-] canvas-mult-item-sel.py
[edit]
[-] bind-w-mult-calls-p-type.py
[edit]
[-] entry-with-shared-variable.pyc
[edit]
[-] radiobutton-simple.pyc
[edit]
[-] dialog-box.py
[edit]
[-] menu-all-types-of-entries.pyo
[edit]
[-] canvas-demo-simple.pyo
[edit]
[-] menu-simple.pyc
[edit]
[-] slider-demo-1.pyo
[edit]
[-] canvas-w-widget-draw-el.py
[edit]
[-] 00-HELLO-WORLD.pyo
[edit]
[-] canvas-demo-simple.py
[edit]
[-] packer-simple.pyo
[edit]
[-] printing-coords-of-items.py
[edit]
[-] printing-coords-of-items.pyc
[edit]
[-] canvas-reading-tag-info.py
[edit]
[-] window-creation-w-location.pyo
[edit]
[-] not-what-you-might-think-1.pyo
[edit]
[-] pong-demo-1.py
[edit]
[-] entry-with-shared-variable.pyo
[edit]
[-] packer-and-placer-together.pyo
[edit]
[-] placer-simple.pyo
[edit]