[Python-checkins] python/dist/src/Demo/tkinter/matt 00-HELLO-WORLD.py, 1.2, 1.3 animation-simple.py, 1.2, 1.3 animation-w-velocity-ctrl.py, 1.3, 1.4 bind-w-mult-calls-p-type.py, 1.2, 1.3 canvas-demo-simple.py, 1.2, 1.3 canvas-gridding.py, 1.2, 1.3 canvas-moving-or-creating.py, 1.3, 1.4 canvas-moving-w-mouse.py, 1.3, 1.4 canvas-mult-item-sel.py, 1.2, 1.3 canvas-reading-tag-info.py, 1.2, 1.3 canvas-w-widget-draw-el.py, 1.2, 1.3 canvas-with-scrollbars.py, 1.3, 1.4 dialog-box.py, 1.2, 1.3 entry-simple.py, 1.1, 1.2 entry-with-shared-variable.py, 1.3, 1.4 killing-window-w-wm.py, 1.2, 1.3 menu-all-types-of-entries.py, 1.2, 1.3 menu-simple.py, 1.4, 1.5 not-what-you-might-think-1.py, 1.2, 1.3 not-what-you-might-think-2.py, 1.2, 1.3 packer-and-placer-together.py, 1.2, 1.3 packer-simple.py, 1.2, 1.3 placer-simple.py, 1.2, 1.3 pong-demo-1.py, 1.3, 1.4 printing-coords-of-items.py, 1.2, 1.3 radiobutton-simple.py, 1.2, 1.3 rubber-band-box-demo-1.py, 1.2, 1.3 rubber-line-demo-1.py, 1.2, 1.3 slider-demo-1.py, 1.2, 1.3 subclass-existing-widgets.py, 1.2, 1.3 two-radio-groups.py, 1.2, 1.3 window-creation-more.py, 1.2, 1.3 window-creation-simple.py, 1.2, 1.3 window-creation-w-location.py, 1.3, 1.4

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Sun Jul 18 08:09:16 CEST 2004


Update of /cvsroot/python/python/dist/src/Demo/tkinter/matt
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30561/matt
Modified Files:
	00-HELLO-WORLD.py animation-simple.py 
	animation-w-velocity-ctrl.py bind-w-mult-calls-p-type.py 
	canvas-demo-simple.py canvas-gridding.py 
	canvas-moving-or-creating.py canvas-moving-w-mouse.py 
	canvas-mult-item-sel.py canvas-reading-tag-info.py 
	canvas-w-widget-draw-el.py canvas-with-scrollbars.py 
	dialog-box.py entry-simple.py entry-with-shared-variable.py 
	killing-window-w-wm.py menu-all-types-of-entries.py 
	menu-simple.py not-what-you-might-think-1.py 
	not-what-you-might-think-2.py packer-and-placer-together.py 
	packer-simple.py placer-simple.py pong-demo-1.py 
	printing-coords-of-items.py radiobutton-simple.py 
	rubber-band-box-demo-1.py rubber-line-demo-1.py 
	slider-demo-1.py subclass-existing-widgets.py 
	two-radio-groups.py window-creation-more.py 
	window-creation-simple.py window-creation-w-location.py 
Log Message:
Whitespace normalization, via reindent.py.
Index: 00-HELLO-WORLD.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/00-HELLO-WORLD.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** 00-HELLO-WORLD.py	30 Jul 1996 18:56:28 -0000	1.2
--- 00-HELLO-WORLD.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,26 ****
 from Tkinter import *
 
! # note that there is no explicit call to start Tk. 
! # Tkinter is smart enough to start the system if it's not already going. 
 
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	# a hello button
! 	self.hi_there = Button(self, text='Hello', 
! 			 command=self.printit)
! 	self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 1,26 ----
 from Tkinter import *
 
! # note that there is no explicit call to start Tk.
! # Tkinter is smart enough to start the system if it's not already going.
 
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
 
! self.QUIT.pack(side=LEFT, fill=BOTH)
! 
! # a hello button
! self.hi_there = Button(self, text='Hello',
! command=self.printit)
! self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: animation-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/animation-simple.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** animation-simple.py	30 Jul 1996 18:56:30 -0000	1.2
--- animation-simple.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 5,32 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	self.draw = Canvas(self, width="5i", height="5i")
 
! 	# all of these work..
! 	self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue")
! 	self.draw.pack(side=LEFT)
 
 def moveThing(self, *args):
! 	# move 1/10 of an inch every 1/10 sec (1" per second, smoothly)
! 	self.draw.move("thing", "0.01i", "0.01i")
! 	self.after(10, self.moveThing)
 
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
! 	self.after(10, self.moveThing)
 
 
--- 5,32 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
 
! self.draw = Canvas(self, width="5i", height="5i")
 
! # all of these work..
! self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue")
! self.draw.pack(side=LEFT)
 
 def moveThing(self, *args):
! # move 1/10 of an inch every 1/10 sec (1" per second, smoothly)
! self.draw.move("thing", "0.01i", "0.01i")
! self.after(10, self.moveThing)
 
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
! self.after(10, self.moveThing)
 
 
Index: animation-w-velocity-ctrl.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/animation-w-velocity-ctrl.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** animation-w-velocity-ctrl.py	12 Feb 2004 17:35:04 -0000	1.3
--- animation-w-velocity-ctrl.py	18 Jul 2004 06:09:09 -0000	1.4
***************
*** 1,41 ****
 from Tkinter import *
 
! # this is the same as simple-demo-1.py, but uses 
! # subclassing. 
! # note that there is no explicit call to start Tk. 
! # Tkinter is smart enough to start the system if it's not already going. 
 
 
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! 	self.draw = Canvas(self, width="5i", height="5i")
 
! 	self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100)
 
! 	self.speed.pack(side=BOTTOM, fill=X)
 
! 	# all of these work..
! 	self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue")
! 	self.draw.pack(side=LEFT)
 
 def moveThing(self, *args):
! 	velocity = self.speed.get()
! 	str = float(velocity) / 1000.0
! 	str = "%ri" % (str,)
! 	self.draw.move("thing", str, str)
! 	self.after(10, self.moveThing)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
! 	self.after(10, self.moveThing)
 
 
--- 1,41 ----
 from Tkinter import *
 
! # this is the same as simple-demo-1.py, but uses
! # subclassing.
! # note that there is no explicit call to start Tk.
! # Tkinter is smart enough to start the system if it's not already going.
 
 
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! self.draw = Canvas(self, width="5i", height="5i")
 
! self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100)
 
! self.speed.pack(side=BOTTOM, fill=X)
 
! # all of these work..
! self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue")
! self.draw.pack(side=LEFT)
 
 def moveThing(self, *args):
! velocity = self.speed.get()
! str = float(velocity) / 1000.0
! str = "%ri" % (str,)
! self.draw.move("thing", str, str)
! self.after(10, self.moveThing)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
! self.after(10, self.moveThing)
 
 
Index: bind-w-mult-calls-p-type.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/bind-w-mult-calls-p-type.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bind-w-mult-calls-p-type.py	30 Jul 1996 18:56:33 -0000	1.2
--- bind-w-mult-calls-p-type.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,4 ****
 from Tkinter import *
! import string 
 
 # This program shows how to use a simple type-in box
--- 1,4 ----
 from Tkinter import *
! import string
 
 # This program shows how to use a simple type-in box
***************
*** 6,33 ****
 class App(Frame):
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	self.pack()
 
! 	self.entrythingy = Entry()
! 	self.entrythingy.pack()
 
! 	# and here we get a callback when the user hits return. we could
! 	# make the key that triggers the callback anything we wanted to.
! 	# other typical options might be <Key-Tab> or <Key> (for anything)
! 	self.entrythingy.bind('<Key-Return>', self.print_contents)
 
! 	# Note that here is where we bind a completely different callback to 
! 	# the same event. We pass "+" here to indicate that we wish to ADD 
! 	# this callback to the list associated with this event type.
! 	# Not specifying "+" would simply override whatever callback was
! 	# defined on this event.
! 	self.entrythingy.bind('<Key-Return>', self.print_something_else, "+")
 
 def print_contents(self, event):
! 	print "hi. contents of entry is now ---->", self.entrythingy.get()
 
 
 def print_something_else(self, event):
! 	print "hi. Now doing something completely different"
 
 
--- 6,33 ----
 class App(Frame):
 def __init__(self, master=None):
! Frame.__init__(self, master)
! self.pack()
 
! self.entrythingy = Entry()
! self.entrythingy.pack()
 
! # and here we get a callback when the user hits return. we could
! # make the key that triggers the callback anything we wanted to.
! # other typical options might be <Key-Tab> or <Key> (for anything)
! self.entrythingy.bind('<Key-Return>', self.print_contents)
 
! # Note that here is where we bind a completely different callback to
! # the same event. We pass "+" here to indicate that we wish to ADD
! # this callback to the list associated with this event type.
! # Not specifying "+" would simply override whatever callback was
! # defined on this event.
! self.entrythingy.bind('<Key-Return>', self.print_something_else, "+")
 
 def print_contents(self, event):
! print "hi. contents of entry is now ---->", self.entrythingy.get()
 
 
 def print_something_else(self, event):
! print "hi. Now doing something completely different"
 
 
***************
*** 38,44 ****
 
 
! # secret tip for experts: if you pass *any* non-false value as 
! # the third parameter to bind(), Tkinter.py will accumulate 
 # callbacks instead of overwriting. I use "+" here because that's
! # the Tk notation for getting this sort of behavior. The perfect GUI 
 # interface would use a less obscure notation.
--- 38,44 ----
 
 
! # secret tip for experts: if you pass *any* non-false value as
! # the third parameter to bind(), Tkinter.py will accumulate
 # callbacks instead of overwriting. I use "+" here because that's
! # the Tk notation for getting this sort of behavior. The perfect GUI
 # interface would use a less obscure notation.
Index: canvas-demo-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-demo-simple.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** canvas-demo-simple.py	30 Jul 1996 18:56:35 -0000	1.2
--- canvas-demo-simple.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 5,26 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! 	self.draw = Canvas(self, width="5i", height="5i")
 
! 	# see the other demos for other ways of specifying coords for a polygon
! 	self.draw.create_rectangle(0, 0, "3i", "3i", fill="black")
 
! 	self.draw.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 5,26 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! self.draw = Canvas(self, width="5i", height="5i")
 
! # see the other demos for other ways of specifying coords for a polygon
! self.draw.create_rectangle(0, 0, "3i", "3i", fill="black")
 
! self.draw.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: canvas-gridding.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-gridding.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** canvas-gridding.py	30 Jul 1996 18:56:37 -0000	1.2
--- canvas-gridding.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,59 ****
 from Tkinter import *
 
! # this is the same as simple-demo-1.py, but uses 
! # subclassing. 
! # note that there is no explicit call to start Tk. 
! # Tkinter is smart enough to start the system if it's not already going. 
 
 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.griddingSize)
! 	self.starty = self.canvasObject.canvasy(event.y, self.griddingSize)
 
 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, self.griddingSize)
! 	y = self.canvasObject.canvasy(event.y, self.griddingSize)
 
! 	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 __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
 
! 	# this is the size of the gridding squares
! 	self.griddingSize = 50
 
- 	Widget.bind(self.canvasObject, "<Button-1>", self.mouseDown)
- 	Widget.bind(self.canvasObject, "<Button1-Motion>", self.mouseMotion)
- 	
 
 test = Test()
--- 1,59 ----
 from Tkinter import *
 
! # this is the same as simple-demo-1.py, but uses
! # subclassing.
! # note that there is no explicit call to start Tk.
! # Tkinter is smart enough to start the system if it's not already going.
 
 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.griddingSize)
! self.starty = self.canvasObject.canvasy(event.y, self.griddingSize)
 
 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, self.griddingSize)
! y = self.canvasObject.canvasy(event.y, self.griddingSize)
 
! 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 __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
 
! # this is the size of the gridding squares
! self.griddingSize = 50
! 
! Widget.bind(self.canvasObject, "<Button-1>", self.mouseDown)
! Widget.bind(self.canvasObject, "<Button1-Motion>", self.mouseMotion)
 
 
 test = Test()
Index: canvas-moving-or-creating.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-moving-or-creating.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** canvas-moving-or-creating.py	24 Sep 1997 13:39:51 -0000	1.3
--- canvas-moving-or-creating.py	18 Jul 2004 06:09:09 -0000	1.4
***************
*** 1,5 ****
 from Tkinter import *
 
! # this file demonstrates a more sophisticated movement -- 
 # move dots or create new ones if you click outside the dots
 
--- 1,5 ----
 from Tkinter import *
 
! # this file demonstrates a more sophisticated movement --
 # move dots or create new ones if you click outside the dots
 
***************
*** 9,33 ****
 ###################################################################
 def mouseDown(self, event):
! 	# see if we're inside a dot. If we are, it
! 	# gets tagged as CURRENT for free by tk.
! 	if not event.widget.find_withtag(CURRENT):
! 	 # there is no dot here, so we can make one,
! 	 # and bind some interesting behavior to it.
! 	 # ------
! 	 # create a dot, and mark it as CURRENT
! 	 fred = self.draw.create_oval(
! 		event.x - 10, event.y -10, event.x +10, event.y + 10,
! 		fill="green", tags=CURRENT)
 
! 	 self.draw.tag_bind(fred, "<Any-Enter>", self.mouseEnter)
! 	 self.draw.tag_bind(fred, "<Any-Leave>", self.mouseLeave)
 
! 	self.lastx = event.x
! 	self.lasty = event.y
 
 def mouseMove(self, event):
! 	self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty)
! 	self.lastx = event.x
! 	self.lasty = event.y
 
 ###################################################################
--- 9,33 ----
 ###################################################################
 def mouseDown(self, event):
! # see if we're inside a dot. If we are, it
! # gets tagged as CURRENT for free by tk.
! if not event.widget.find_withtag(CURRENT):
! # there is no dot here, so we can make one,
! # and bind some interesting behavior to it.
! # ------
! # create a dot, and mark it as CURRENT
! fred = self.draw.create_oval(
! event.x - 10, event.y -10, event.x +10, event.y + 10,
! fill="green", tags=CURRENT)
 
! self.draw.tag_bind(fred, "<Any-Enter>", self.mouseEnter)
! self.draw.tag_bind(fred, "<Any-Leave>", self.mouseLeave)
 
! self.lastx = event.x
! self.lasty = event.y
 
 def mouseMove(self, event):
! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty)
! self.lastx = event.x
! self.lasty = event.y
 
 ###################################################################
***************
*** 36,65 ****
 def mouseEnter(self, event):
 # the CURRENT tag is applied to the object the cursor is over.
! 	# this happens automatically.
! 	self.draw.itemconfig(CURRENT, fill="red")
 
 def mouseLeave(self, event):
! 	# the CURRENT tag is applied to the object the cursor is over.
! 	# this happens automatically.
! 	self.draw.itemconfig(CURRENT, fill="blue")
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
! 	self.draw = Canvas(self, width="5i", height="5i")
! 	self.draw.pack(side=LEFT)
 
! 	Widget.bind(self.draw, "<1>", self.mouseDown)
! 	Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
 test.mainloop()
- 
- 
- 
--- 36,62 ----
 def mouseEnter(self, event):
 # the CURRENT tag is applied to the object the cursor is over.
! # this happens automatically.
! self.draw.itemconfig(CURRENT, fill="red")
 
 def mouseLeave(self, event):
! # the CURRENT tag is applied to the object the cursor is over.
! # this happens automatically.
! self.draw.itemconfig(CURRENT, fill="blue")
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
! self.draw = Canvas(self, width="5i", height="5i")
! self.draw.pack(side=LEFT)
 
! Widget.bind(self.draw, "<1>", self.mouseDown)
! Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
 test.mainloop()
Index: canvas-moving-w-mouse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-moving-w-mouse.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** canvas-moving-w-mouse.py	30 Jul 1996 18:56:38 -0000	1.3
--- canvas-moving-w-mouse.py	18 Jul 2004 06:09:09 -0000	1.4
***************
*** 8,20 ****
 ###################################################################
 def mouseDown(self, event):
! 	# remember where the mouse went down
! 	self.lastx = event.x
! 	self.lasty = event.y
 
 def mouseMove(self, event):
! 	# whatever the mouse is over gets tagged as CURRENT for free by tk.
! 	self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty)
! 	self.lastx = event.x
! 	self.lasty = event.y
 
 ###################################################################
--- 8,20 ----
 ###################################################################
 def mouseDown(self, event):
! # remember where the mouse went down
! self.lastx = event.x
! self.lasty = event.y
 
 def mouseMove(self, event):
! # whatever the mouse is over gets tagged as CURRENT for free by tk.
! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty)
! self.lastx = event.x
! self.lasty = event.y
 
 ###################################################################
***************
*** 23,54 ****
 def mouseEnter(self, event):
 # the CURRENT tag is applied to the object the cursor is over.
! 	# this happens automatically.
! 	self.draw.itemconfig(CURRENT, fill="red")
! 	
 def mouseLeave(self, event):
! 	# the CURRENT tag is applied to the object the cursor is over.
! 	# this happens automatically.
! 	self.draw.itemconfig(CURRENT, fill="blue")
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
! 	self.draw = Canvas(self, width="5i", height="5i")
! 	self.draw.pack(side=LEFT)
 
! 	fred = self.draw.create_oval(0, 0, 20, 20,
! 				 fill="green", tags="selected")
 
! 	self.draw.tag_bind(fred, "<Any-Enter>", self.mouseEnter)
! 	self.draw.tag_bind(fred, "<Any-Leave>", self.mouseLeave)
 
! 	Widget.bind(self.draw, "<1>", self.mouseDown)
! 	Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 23,54 ----
 def mouseEnter(self, event):
 # the CURRENT tag is applied to the object the cursor is over.
! # this happens automatically.
! self.draw.itemconfig(CURRENT, fill="red")
! 
 def mouseLeave(self, event):
! # the CURRENT tag is applied to the object the cursor is over.
! # this happens automatically.
! self.draw.itemconfig(CURRENT, fill="blue")
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
! self.draw = Canvas(self, width="5i", height="5i")
! self.draw.pack(side=LEFT)
 
! fred = self.draw.create_oval(0, 0, 20, 20,
! fill="green", tags="selected")
 
! self.draw.tag_bind(fred, "<Any-Enter>", self.mouseEnter)
! self.draw.tag_bind(fred, "<Any-Leave>", self.mouseLeave)
 
! Widget.bind(self.draw, "<1>", self.mouseDown)
! Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: canvas-mult-item-sel.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-mult-item-sel.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** canvas-mult-item-sel.py	30 Jul 1996 18:56:41 -0000	1.2
--- canvas-mult-item-sel.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,5 ****
 from Tkinter import *
 
! # allows moving dots with multiple selection. 
 
 SELECTED_COLOR = "red"
--- 1,5 ----
 from Tkinter import *
 
! # allows moving dots with multiple selection.
 
 SELECTED_COLOR = "red"
***************
*** 11,81 ****
 ###################################################################
 def mouseDown(self, event):
! 	# see if we're inside a dot. If we are, it
! 	# gets tagged as CURRENT for free by tk.
 
- 	if not event.widget.find_withtag(CURRENT):
- 	 # we clicked outside of all dots on the canvas. unselect all.
- 	 
- 	 # re-color everything back to an unselected color
- 	 self.draw.itemconfig("selected", fill=UNSELECTED_COLOR)
- 	 # unselect everything
- 	 self.draw.dtag("selected")
- 	else:
- 	 # mark as "selected" the thing the cursor is under
- 	 self.draw.addtag("selected", "withtag", CURRENT)
- 	 # color it as selected
- 	 self.draw.itemconfig("selected", fill=SELECTED_COLOR)
 
- 	self.lastx = event.x
- 	self.lasty = event.y
- 		
- 	
 def mouseMove(self, event):
! 	self.draw.move("selected", event.x - self.lastx, event.y - self.lasty)
! 	self.lastx = event.x
! 	self.lasty = event.y
 
 def makeNewDot(self):
! 	# create a dot, and mark it as current
! 	fred = self.draw.create_oval(0, 0, 20, 20, 
! 				 fill=SELECTED_COLOR, tags=CURRENT)
! 	# and make it selected
! 	self.draw.addtag("selected", "withtag", CURRENT)
! 	
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red',
! 			 command=self.quit)
 
! 	################
! 	# make the canvas and bind some behavior to it
! 	################
! 	self.draw = Canvas(self, width="5i", height="5i")
! 	Widget.bind(self.draw, "<1>", self.mouseDown)
! 	Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
! 	# and other things.....
! 	self.button = Button(self, text="make a new dot", foreground="blue",
! 			 command=self.makeNewDot)
 
! 	message = ("%s dots are selected and can be dragged.\n"
! 		 "%s are not selected.\n"
! 		 "Click in a dot to select it.\n"
! 		 "Click on empty space to deselect all dots."
! 		 ) % (SELECTED_COLOR, UNSELECTED_COLOR)
! 	self.label = Message(self, width="5i", text=message)
 
! 	self.QUIT.pack(side=BOTTOM, fill=BOTH)
! 	self.label.pack(side=BOTTOM, fill=X, expand=1)
! 	self.button.pack(side=BOTTOM, fill=X)
! 	self.draw.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
 test.mainloop()
- 
- 
- 
--- 11,78 ----
 ###################################################################
 def mouseDown(self, event):
! # see if we're inside a dot. If we are, it
! # gets tagged as CURRENT for free by tk.
! 
! if not event.widget.find_withtag(CURRENT):
! # we clicked outside of all dots on the canvas. unselect all.
! 
! # re-color everything back to an unselected color
! self.draw.itemconfig("selected", fill=UNSELECTED_COLOR)
! # unselect everything
! self.draw.dtag("selected")
! else:
! # mark as "selected" the thing the cursor is under
! self.draw.addtag("selected", "withtag", CURRENT)
! # color it as selected
! self.draw.itemconfig("selected", fill=SELECTED_COLOR)
! 
! self.lastx = event.x
! self.lasty = event.y
 
 
 def mouseMove(self, event):
! self.draw.move("selected", event.x - self.lastx, event.y - self.lasty)
! self.lastx = event.x
! self.lasty = event.y
 
 def makeNewDot(self):
! # create a dot, and mark it as current
! fred = self.draw.create_oval(0, 0, 20, 20,
! fill=SELECTED_COLOR, tags=CURRENT)
! # and make it selected
! self.draw.addtag("selected", "withtag", CURRENT)
! 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
 
! ################
! # make the canvas and bind some behavior to it
! ################
! self.draw = Canvas(self, width="5i", height="5i")
! Widget.bind(self.draw, "<1>", self.mouseDown)
! Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
! # and other things.....
! self.button = Button(self, text="make a new dot", foreground="blue",
! command=self.makeNewDot)
 
! message = ("%s dots are selected and can be dragged.\n"
! "%s are not selected.\n"
! "Click in a dot to select it.\n"
! "Click on empty space to deselect all dots."
! ) % (SELECTED_COLOR, UNSELECTED_COLOR)
! self.label = Message(self, width="5i", text=message)
 
! self.QUIT.pack(side=BOTTOM, fill=BOTH)
! self.label.pack(side=BOTTOM, fill=X, expand=1)
! self.button.pack(side=BOTTOM, fill=X)
! self.draw.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
 test.mainloop()
Index: canvas-reading-tag-info.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-reading-tag-info.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** canvas-reading-tag-info.py	30 Jul 1996 18:56:43 -0000	1.2
--- canvas-reading-tag-info.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 4,47 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! 	self.drawing = Canvas(self, width="5i", height="5i")
 
! 	# make a shape
! 	pgon = self.drawing.create_polygon(
! 	 10, 10, 110, 10, 110, 110, 10 , 110,
! 	 fill="red", tags=("weee", "foo", "groo"))
 
! 	# this is how you query an object for its attributes 
! 	# config options FOR CANVAS ITEMS always come back in tuples of length 5.
! 	# 0 attribute name
! 	# 1 BLANK 
! 	# 2 BLANK 
! 	# 3 default value
! 	# 4 current value
! 	# the blank spots are for consistency with the config command that 
! 	# is used for widgets. (remember, this is for ITEMS drawn 
! 	# on a canvas widget, not widgets)
! 	option_value = self.drawing.itemconfig(pgon, "stipple")
! 	print "pgon's current stipple value is -->", option_value[4], "<--"
! 	option_value = self.drawing.itemconfig(pgon, "fill")
! 	print "pgon's current fill value is -->", option_value[4], "<--"
! 	print " when he is usually colored -->", option_value[3], "<--"
 
! 	## here we print out all the tags associated with this object
! 	option_value = self.drawing.itemconfig(pgon, "tags")
! 	print "pgon's tags are", option_value[4]
 
! 	self.drawing.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 4,47 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! self.drawing = Canvas(self, width="5i", height="5i")
 
! # make a shape
! pgon = self.drawing.create_polygon(
! 10, 10, 110, 10, 110, 110, 10 , 110,
! fill="red", tags=("weee", "foo", "groo"))
 
! # this is how you query an object for its attributes
! # config options FOR CANVAS ITEMS always come back in tuples of length 5.
! # 0 attribute name
! # 1 BLANK
! # 2 BLANK
! # 3 default value
! # 4 current value
! # the blank spots are for consistency with the config command that
! # is used for widgets. (remember, this is for ITEMS drawn
! # on a canvas widget, not widgets)
! option_value = self.drawing.itemconfig(pgon, "stipple")
! print "pgon's current stipple value is -->", option_value[4], "<--"
! option_value = self.drawing.itemconfig(pgon, "fill")
! print "pgon's current fill value is -->", option_value[4], "<--"
! print " when he is usually colored -->", option_value[3], "<--"
 
! ## here we print out all the tags associated with this object
! option_value = self.drawing.itemconfig(pgon, "tags")
! print "pgon's tags are", option_value[4]
 
! self.drawing.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: canvas-w-widget-draw-el.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-w-widget-draw-el.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** canvas-w-widget-draw-el.py	30 Jul 1996 18:56:46 -0000	1.2
--- canvas-w-widget-draw-el.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 5,34 ****
 class Test(Frame):
 def printhi(self):
! 	print "hi"
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! 	self.draw = Canvas(self, width="5i", height="5i")
 
! 	self.button = Button(self, text="this is a button", 
! 			 command=self.printhi)
 
! 	# note here the coords are given in pixels (form the 
! 	# upper right and corner of the window, as usual for X) 
! 	# but might just have well been given in inches or points or
! 	# whatever...use the "anchor" option to control what point of the 
! 	# widget (in this case the button) gets mapped to the given x, y. 
! 	# you can specify corners, edges, center, etc...
! 	self.draw.create_window(300, 300, window=self.button)
 
! 	self.draw.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 5,34 ----
 class Test(Frame):
 def printhi(self):
! print "hi"
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
! self.draw = Canvas(self, width="5i", height="5i")
 
! self.button = Button(self, text="this is a button",
! command=self.printhi)
 
! # note here the coords are given in pixels (form the
! # upper right and corner of the window, as usual for X)
! # but might just have well been given in inches or points or
! # whatever...use the "anchor" option to control what point of the
! # widget (in this case the button) gets mapped to the given x, y.
! # you can specify corners, edges, center, etc...
! self.draw.create_window(300, 300, window=self.button)
 
! self.draw.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: canvas-with-scrollbars.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/canvas-with-scrollbars.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** canvas-with-scrollbars.py	30 Jul 1996 18:56:44 -0000	1.3
--- canvas-with-scrollbars.py	18 Jul 2004 06:09:09 -0000	1.4
***************
*** 1,5 ****
 from Tkinter import *
 
! # This example program creates a scroling canvas, and demonstrates 
 # how to tie scrollbars and canvses together. The mechanism
 # is analogus for listboxes and other widgets with
--- 1,5 ----
 from Tkinter import *
 
! # This example program creates a scroling canvas, and demonstrates
 # how to tie scrollbars and canvses together. The mechanism
 # is analogus for listboxes and other widgets with
***************
*** 8,58 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def createWidgets(self):
! 	self.question = Label(self, text="Can Find The BLUE Square??????")
! 	self.question.pack()
 
! 	self.QUIT = Button(self, text='QUIT', background='red', 
! 			 height=3, command=self.quit)
! 	self.QUIT.pack(side=BOTTOM, fill=BOTH)	
! 	spacer = Frame(self, height="0.25i")
! 	spacer.pack(side=BOTTOM)
 
! 	# notice that the scroll region (20" x 20") is larger than 
! 	# displayed size of the widget (5" x 5")
! 	self.draw = Canvas(self, width="5i", height="5i",
! 			 background="white",
! 			 scrollregion=(0, 0, "20i", "20i"))
 
! 	self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL)
! 	self.draw.scrollY = Scrollbar(self, orient=VERTICAL)
 
! 	# now tie the three together. This is standard boilerplate text
! 	self.draw['xscrollcommand'] = self.draw.scrollX.set
! 	self.draw['yscrollcommand'] = self.draw.scrollY.set
! 	self.draw.scrollX['command'] = self.draw.xview
! 	self.draw.scrollY['command'] = self.draw.yview
 
! 	# draw something. Note that the first square 
! 	# is visible, but you need to scroll to see the second one.
! 	self.draw.create_rectangle(0, 0, "3.5i", "3.5i", fill="black")
! 	self.draw.create_rectangle("10i", "10i", "13.5i", "13.5i", fill="blue")
 
! 	# pack 'em up
! 	self.draw.scrollX.pack(side=BOTTOM, fill=X)
! 	self.draw.scrollY.pack(side=RIGHT, fill=Y)
! 	self.draw.pack(side=LEFT)
 
 
! def scrollCanvasX(self, *args): 
! 	print "scrolling", args
! 	print self.draw.scrollX.get()
 
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 8,58 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def createWidgets(self):
! self.question = Label(self, text="Can Find The BLUE Square??????")
! self.question.pack()
 
! self.QUIT = Button(self, text='QUIT', background='red',
! height=3, command=self.quit)
! self.QUIT.pack(side=BOTTOM, fill=BOTH)
! spacer = Frame(self, height="0.25i")
! spacer.pack(side=BOTTOM)
 
! # notice that the scroll region (20" x 20") is larger than
! # displayed size of the widget (5" x 5")
! self.draw = Canvas(self, width="5i", height="5i",
! background="white",
! scrollregion=(0, 0, "20i", "20i"))
 
! self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL)
! self.draw.scrollY = Scrollbar(self, orient=VERTICAL)
 
! # now tie the three together. This is standard boilerplate text
! self.draw['xscrollcommand'] = self.draw.scrollX.set
! self.draw['yscrollcommand'] = self.draw.scrollY.set
! self.draw.scrollX['command'] = self.draw.xview
! self.draw.scrollY['command'] = self.draw.yview
 
! # draw something. Note that the first square
! # is visible, but you need to scroll to see the second one.
! self.draw.create_rectangle(0, 0, "3.5i", "3.5i", fill="black")
! self.draw.create_rectangle("10i", "10i", "13.5i", "13.5i", fill="blue")
 
! # pack 'em up
! self.draw.scrollX.pack(side=BOTTOM, fill=X)
! self.draw.scrollY.pack(side=RIGHT, fill=Y)
! self.draw.pack(side=LEFT)
 
 
! def scrollCanvasX(self, *args):
! print "scrolling", args
! print self.draw.scrollX.get()
 
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: dialog-box.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/dialog-box.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** dialog-box.py	30 Jul 1996 18:56:47 -0000	1.2
--- dialog-box.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 7,63 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def makeWindow(self):
! 	"""Create a top-level dialog with some buttons.
 
! 	This uses the Dialog class, which is a wrapper around the Tcl/Tk
! 	tk_dialog script. The function returns 0 if the user clicks 'yes'
! 	or 1 if the user clicks 'no'.
! 	"""
! 	# the parameters to this call are as follows: 
! 	d = Dialog(
! 	 self,			## name of a toplevel window
! 	 title="fred the dialog box",## title on the window
! 	 text="click on a choice",	## message to appear in window
! 	 bitmap="info",		## bitmap (if any) to appear;
! 					## if none, use ""
! 	 # legal values here are:
! 	 # string what it looks like
! 	 # ----------------------------------------------
! 	 # error a circle with a slash through it
! 	 #	 grey25 grey square
! 	 #	 grey50 darker grey square
! 	 #	 hourglass use for "wait.."
! 	 #	 info a large, lower case "i"
! 	 #	 questhead a human head with a "?" in it
! 	 #	 question a large "?"
! 	 #	 warning a large "!" 
! 	 # @fname X bitmap where fname is the path to the file 
! 	 #
! 	 default=0, # the index of the default button choice.
! 			 # hitting return selects this
! 	 strings=("yes", "no"))
! 			 # values of the 'strings' key are the labels for the 
! 			 # buttons that appear left to right in the dialog box
! 	return d.num
 
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)	
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	# a hello button
! 	self.hi_there = Button(self, text='Make a New Window', 
! 			 command=self.makeWindow)
! 	self.hi_there.pack(side=LEFT)
 
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.windownum = 0 
! 	self.createWidgets()
 
 test = Test()
--- 7,63 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def makeWindow(self):
! """Create a top-level dialog with some buttons.
 
! This uses the Dialog class, which is a wrapper around the Tcl/Tk
! tk_dialog script. The function returns 0 if the user clicks 'yes'
! or 1 if the user clicks 'no'.
! """
! # the parameters to this call are as follows:
! d = Dialog(
! self, ## name of a toplevel window
! title="fred the dialog box",## title on the window
! text="click on a choice", ## message to appear in window
! bitmap="info", ## bitmap (if any) to appear;
! ## if none, use ""
! # legal values here are:
! # string what it looks like
! # ----------------------------------------------
! # error a circle with a slash through it
! # grey25 grey square
! # grey50 darker grey square
! # hourglass use for "wait.."
! # info a large, lower case "i"
! # questhead a human head with a "?" in it
! # question a large "?"
! # warning a large "!"
! # @fname X bitmap where fname is the path to the file
! #
! default=0, # the index of the default button choice.
! # hitting return selects this
! strings=("yes", "no"))
! # values of the 'strings' key are the labels for the
! # buttons that appear left to right in the dialog box
! return d.num
 
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
 
! # a hello button
! self.hi_there = Button(self, text='Make a New Window',
! command=self.makeWindow)
! self.hi_there.pack(side=LEFT)
 
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.windownum = 0
! self.createWidgets()
 
 test = Test()
Index: entry-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/entry-simple.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** entry-simple.py	7 Oct 1994 09:53:59 -0000	1.1
--- entry-simple.py	18 Jul 2004 06:09:09 -0000	1.2
***************
*** 1,4 ****
 from Tkinter import *
! import string 
 
 # This program shows how to use a simple type-in box
--- 1,4 ----
 from Tkinter import *
! import string
 
 # This program shows how to use a simple type-in box
***************
*** 6,25 ****
 class App(Frame):
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	self.pack()
 
! 	self.entrythingy = Entry()
! 	self.entrythingy.pack()
 
! 	# and here we get a callback when the user hits return. we could
! 	# make the key that triggers the callback anything we wanted to.
! 	# other typical options might be <Key-Tab> or <Key> (for anything)
! 	self.entrythingy.bind('<Key-Return>', self.print_contents)
 
 def print_contents(self, event):
! 	print "hi. contents of entry is now ---->", self.entrythingy.get()
 
 root = App()
 root.master.title("Foo")
 root.mainloop()
- 
--- 6,24 ----
 class App(Frame):
 def __init__(self, master=None):
! Frame.__init__(self, master)
! self.pack()
 
! self.entrythingy = Entry()
! self.entrythingy.pack()
 
! # and here we get a callback when the user hits return. we could
! # make the key that triggers the callback anything we wanted to.
! # other typical options might be <Key-Tab> or <Key> (for anything)
! self.entrythingy.bind('<Key-Return>', self.print_contents)
 
 def print_contents(self, event):
! print "hi. contents of entry is now ---->", self.entrythingy.get()
 
 root = App()
 root.master.title("Foo")
 root.mainloop()
Index: entry-with-shared-variable.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/entry-with-shared-variable.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** entry-with-shared-variable.py	27 Nov 1996 19:47:42 -0000	1.3
--- entry-with-shared-variable.py	18 Jul 2004 06:09:09 -0000	1.4
***************
*** 1,4 ****
 from Tkinter import *
! import string 
 
 # This program shows how to make a typein box shadow a program variable.
--- 1,4 ----
 from Tkinter import *
! import string
 
 # This program shows how to make a typein box shadow a program variable.
***************
*** 6,47 ****
 class App(Frame):
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	self.pack()
 
! 	self.entrythingy = Entry(self)
! 	self.entrythingy.pack()
 
! 	self.button = Button(self, text="Uppercase The Entry",
! 			 command=self.upper)
! 	self.button.pack()
 
! 	# here we have the text in the entry widget tied to a variable.
! 	# changes in the variable are echoed in the widget and vice versa. 
! 	# Very handy.
! 	# there are other Variable types. See Tkinter.py for all
! 	# the other variable types that can be shadowed
! 	self.contents = StringVar()
! 	self.contents.set("this is a variable")
! 	self.entrythingy.config(textvariable=self.contents)
 
! 	# and here we get a callback when the user hits return. we could
! 	# make the key that triggers the callback anything we wanted to.
! 	# other typical options might be <Key-Tab> or <Key> (for anything)
! 	self.entrythingy.bind('<Key-Return>', self.print_contents)
 
 def upper(self):
! 	# notice here, we don't actually refer to the entry box.
! 	# we just operate on the string variable and we 
 # because it's being looked at by the entry widget, changing
! 	# the variable changes the entry widget display automatically.
! 	# the strange get/set operators are clunky, true...
! 	str = string.upper(self.contents.get())
! 	self.contents.set(str)
 
 def print_contents(self, event):
! 	print "hi. contents of entry is now ---->", self.contents.get()
 
 root = App()
 root.master.title("Foo")
 root.mainloop()
- 
--- 6,46 ----
 class App(Frame):
 def __init__(self, master=None):
! Frame.__init__(self, master)
! self.pack()
 
! self.entrythingy = Entry(self)
! self.entrythingy.pack()
 
! self.button = Button(self, text="Uppercase The Entry",
! command=self.upper)
! self.button.pack()
 
! # here we have the text in the entry widget tied to a variable.
! # changes in the variable are echoed in the widget and vice versa.
! # Very handy.
! # there are other Variable types. See Tkinter.py for all
! # the other variable types that can be shadowed
! self.contents = StringVar()
! self.contents.set("this is a variable")
! self.entrythingy.config(textvariable=self.contents)
 
! # and here we get a callback when the user hits return. we could
! # make the key that triggers the callback anything we wanted to.
! # other typical options might be <Key-Tab> or <Key> (for anything)
! self.entrythingy.bind('<Key-Return>', self.print_contents)
 
 def upper(self):
! # notice here, we don't actually refer to the entry box.
! # we just operate on the string variable and we
 # because it's being looked at by the entry widget, changing
! # the variable changes the entry widget display automatically.
! # the strange get/set operators are clunky, true...
! str = string.upper(self.contents.get())
! self.contents.set(str)
 
 def print_contents(self, event):
! print "hi. contents of entry is now ---->", self.contents.get()
 
 root = App()
 root.master.title("Foo")
 root.mainloop()
Index: killing-window-w-wm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/killing-window-w-wm.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** killing-window-w-wm.py	30 Jul 1996 18:56:50 -0000	1.2
--- killing-window-w-wm.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,7 ****
 from Tkinter import *
 
! # This file shows how to trap the killing of a window 
 # when the user uses window manager menus (typ. upper left hand corner
! # menu in the decoration border). 
 
 
--- 1,7 ----
 from Tkinter import *
 
! # This file shows how to trap the killing of a window
 # when the user uses window manager menus (typ. upper left hand corner
! # menu in the decoration border).
 
 
***************
*** 12,40 ****
 class Test(Frame):
 def deathHandler(self, event):
! 	print self, "is now getting nuked. performing some save here...."
 
 def createWidgets(self):
! 	# a hello button
! 	self.hi_there = Button(self, text='Hello')
! 	self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
! 	###
! 	### PREVENT WM kills from happening
! 	###
 
! 	# the docs would have you do this: 
 
! #	self.master.protocol("WM_DELETE_WINDOW", my_delete_callback)
 
! 	# unfortunately, some window managers will not send this request to a window.
! 	# the "protocol" function seems incapable of trapping these "aggressive" window kills.
! 	# this line of code catches everything, tho. The window is deleted, but you have a chance
! 	# of cleaning up first.
! 	self.bind_all("<Destroy>", self.deathHandler)
 
 
--- 12,40 ----
 class Test(Frame):
 def deathHandler(self, event):
! print self, "is now getting nuked. performing some save here...."
 
 def createWidgets(self):
! # a hello button
! self.hi_there = Button(self, text='Hello')
! self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
! ###
! ### PREVENT WM kills from happening
! ###
 
! # the docs would have you do this:
 
! # self.master.protocol("WM_DELETE_WINDOW", my_delete_callback)
 
! # unfortunately, some window managers will not send this request to a window.
! # the "protocol" function seems incapable of trapping these "aggressive" window kills.
! # this line of code catches everything, tho. The window is deleted, but you have a chance
! # of cleaning up first.
! self.bind_all("<Destroy>", self.deathHandler)
 
 
Index: menu-all-types-of-entries.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/menu-all-types-of-entries.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** menu-all-types-of-entries.py	30 Jul 1996 18:56:52 -0000	1.2
--- menu-all-types-of-entries.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,15 ****
 from Tkinter import *
 
! # some vocabulary to keep from getting confused. This terminology 
! # is something I cooked up for this file, but follows the man pages 
 # pretty closely
! # 
! # 
! # 
 # This is a MENUBUTTON
 # V
 # +-------------+
 # | |
! # 
 # +------------++------------++------------+
 # | || || |
--- 1,15 ----
 from Tkinter import *
 
! # some vocabulary to keep from getting confused. This terminology
! # is something I cooked up for this file, but follows the man pages
 # pretty closely
! #
! #
! #
 # This is a MENUBUTTON
 # V
 # +-------------+
 # | |
! #
 # +------------++------------++------------+
 # | || || |
***************
*** 23,27 ****
 # | | MENU ENTRIES
 # | +---------------+
! # | Open Files > | file1 | 
 # | | file2 |
 # | | another file | <------ this cascading part is also a MENU
--- 23,27 ----
 # | | MENU ENTRIES
 # | +---------------+
! # | Open Files > | file1 |
 # | | file2 |
 # | | another file | <------ this cascading part is also a MENU
***************
*** 54,62 ****
 
 def makeCommandMenu():
! # make menu button 
! Command_button = Menubutton(mBar, text='Simple Button Commands', 
! 				underline=0)
 Command_button.pack(side=LEFT, padx="2m")
! 
 # make the pulldown part of the File menu. The parameter passed is the master.
 # we attach it to the button as a python attribute called "menu" by convention.
--- 54,62 ----
 
 def makeCommandMenu():
! # make menu button
! Command_button = Menubutton(mBar, text='Simple Button Commands',
! underline=0)
 Command_button.pack(side=LEFT, padx="2m")
! 
 # make the pulldown part of the File menu. The parameter passed is the master.
 # we attach it to the button as a python attribute called "menu" by convention.
***************
*** 69,94 ****
 Command_button.menu.entryconfig(0, state=DISABLED)
 
! Command_button.menu.add_command(label='New...', underline=0, 
! 				 command=new_file)
! Command_button.menu.add_command(label='Open...', underline=0, 
! 				 command=open_file)
 Command_button.menu.add_command(label='Different Font', underline=0,
! 				 font='-*-helvetica-*-r-*-*-*-180-*-*-*-*-*-*',
! 				 command=print_something)
! 
 # we can make bitmaps be menu entries too. File format is X11 bitmap.
 # if you use XV, save it under X11 bitmap format. duh-uh.,..
 Command_button.menu.add_command(
! 	bitmap="info")
! 	#bitmap='@/home/mjc4y/dilbert/project.status.is.doomed.last.panel.bm')
! 
 # this is just a line
 Command_button.menu.add('separator')
 
 # change the color
! Command_button.menu.add_command(label='Quit', underline=0, 
! 				 background='red', 
! 				 activebackground='green', 
! 				 command=Command_button.quit)
 
 # set up a pointer from the file menubutton back to the file menu
--- 69,94 ----
 Command_button.menu.entryconfig(0, state=DISABLED)
 
! Command_button.menu.add_command(label='New...', underline=0,
! command=new_file)
! Command_button.menu.add_command(label='Open...', underline=0,
! command=open_file)
 Command_button.menu.add_command(label='Different Font', underline=0,
! font='-*-helvetica-*-r-*-*-*-180-*-*-*-*-*-*',
! command=print_something)
! 
 # we can make bitmaps be menu entries too. File format is X11 bitmap.
 # if you use XV, save it under X11 bitmap format. duh-uh.,..
 Command_button.menu.add_command(
! bitmap="info")
! #bitmap='@/home/mjc4y/dilbert/project.status.is.doomed.last.panel.bm')
! 
 # this is just a line
 Command_button.menu.add('separator')
 
 # change the color
! Command_button.menu.add_command(label='Quit', underline=0,
! background='red',
! activebackground='green',
! command=Command_button.quit)
 
 # set up a pointer from the file menubutton back to the file menu
***************
*** 100,107 ****
 
 def makeCascadeMenu():
! # make menu button 
 Cascade_button = Menubutton(mBar, text='Cascading Menus', underline=0)
 Cascade_button.pack(side=LEFT, padx="2m")
! 
 # the primary pulldown
 Cascade_button.menu = Menu(Cascade_button)
--- 100,107 ----
 
 def makeCascadeMenu():
! # make menu button
 Cascade_button = Menubutton(mBar, text='Cascading Menus', underline=0)
 Cascade_button.pack(side=LEFT, padx="2m")
! 
 # the primary pulldown
 Cascade_button.menu = Menu(Cascade_button)
***************
*** 126,135 ****
 Cascade_button.menu.choices.add_command(label='BubbleGum')
 Cascade_button.menu.choices.add_cascade(
! 	label='Wierd Flavors', 
! 	menu=Cascade_button.menu.choices.wierdones)
 
 # and finally, the definition for the top level
! Cascade_button.menu.add_cascade(label='more choices', 
! 				 menu=Cascade_button.menu.choices)
 
 Cascade_button['menu'] = Cascade_button.menu
--- 126,135 ----
 Cascade_button.menu.choices.add_command(label='BubbleGum')
 Cascade_button.menu.choices.add_cascade(
! label='Wierd Flavors',
! menu=Cascade_button.menu.choices.wierdones)
 
 # and finally, the definition for the top level
! Cascade_button.menu.add_cascade(label='more choices',
! menu=Cascade_button.menu.choices)
 
 Cascade_button['menu'] = Cascade_button.menu
***************
*** 139,152 ****
 def makeCheckbuttonMenu():
 global fred
! # make menu button 
! Checkbutton_button = Menubutton(mBar, text='Checkbutton Menus', 
! 				 underline=0)
 Checkbutton_button.pack(side=LEFT, padx='2m')
! 
 # the primary pulldown
 Checkbutton_button.menu = Menu(Checkbutton_button)
 
 # and all the check buttons. Note that the "variable" "onvalue" and "offvalue" options
! # are not supported correctly at present. You have to do all your application 
 # work through the calback.
 Checkbutton_button.menu.add_checkbutton(label='Pepperoni')
--- 139,152 ----
 def makeCheckbuttonMenu():
 global fred
! # make menu button
! Checkbutton_button = Menubutton(mBar, text='Checkbutton Menus',
! underline=0)
 Checkbutton_button.pack(side=LEFT, padx='2m')
! 
 # the primary pulldown
 Checkbutton_button.menu = Menu(Checkbutton_button)
 
 # and all the check buttons. Note that the "variable" "onvalue" and "offvalue" options
! # are not supported correctly at present. You have to do all your application
 # work through the calback.
 Checkbutton_button.menu.add_checkbutton(label='Pepperoni')
***************
*** 155,169 ****
 
 # so here's a callback
! Checkbutton_button.menu.add_checkbutton(label='Anchovy', 
! 					 command=print_anchovies)
 
! # and start with anchovies selected to be on. Do this by 
 # calling invoke on this menu option. To refer to the "anchovy" menu
 # entry we need to know it's index. To do this, we use the index method
! # which takes arguments of several forms: 
 #
 # argument what it does
 # -----------------------------------
! # a number -- this is useless. 
 # "last" -- last option in the menu
 # "none" -- used with the activate command. see the man page on menus
--- 155,169 ----
 
 # so here's a callback
! Checkbutton_button.menu.add_checkbutton(label='Anchovy',
! command=print_anchovies)
 
! # and start with anchovies selected to be on. Do this by
 # calling invoke on this menu option. To refer to the "anchovy" menu
 # entry we need to know it's index. To do this, we use the index method
! # which takes arguments of several forms:
 #
 # argument what it does
 # -----------------------------------
! # a number -- this is useless.
 # "last" -- last option in the menu
 # "none" -- used with the activate command. see the man page on menus
***************
*** 171,175 ****
 # with the 'activate' method
 # "@number" -- where 'number' is an integer and is treated like a y coordinate in pixels
! # string pattern -- this is the option used below, and attempts to match "labels" using the 
 # rules of Tcl_StringMatch
 Checkbutton_button.menu.invoke(Checkbutton_button.menu.index('Anchovy'))
--- 171,175 ----
 # with the 'activate' method
 # "@number" -- where 'number' is an integer and is treated like a y coordinate in pixels
! # string pattern -- this is the option used below, and attempts to match "labels" using the
 # rules of Tcl_StringMatch
 Checkbutton_button.menu.invoke(Checkbutton_button.menu.index('Anchovy'))
***************
*** 182,195 ****
 
 def makeRadiobuttonMenu():
! # make menu button 
! Radiobutton_button = Menubutton(mBar, text='Radiobutton Menus', 
! 				 underline=0)
 Radiobutton_button.pack(side=LEFT, padx='2m')
! 
 # the primary pulldown
 Radiobutton_button.menu = Menu(Radiobutton_button)
 
 # and all the Radio buttons. Note that the "variable" "onvalue" and "offvalue" options
! # are not supported correctly at present. You have to do all your application 
 # work through the calback.
 Radiobutton_button.menu.add_radiobutton(label='Republican')
--- 182,195 ----
 
 def makeRadiobuttonMenu():
! # make menu button
! Radiobutton_button = Menubutton(mBar, text='Radiobutton Menus',
! underline=0)
 Radiobutton_button.pack(side=LEFT, padx='2m')
! 
 # the primary pulldown
 Radiobutton_button.menu = Menu(Radiobutton_button)
 
 # and all the Radio buttons. Note that the "variable" "onvalue" and "offvalue" options
! # are not supported correctly at present. You have to do all your application
 # work through the calback.
 Radiobutton_button.menu.add_radiobutton(label='Republican')
***************
*** 210,214 ****
 
 
! def makeDisabledMenu(): 
 Dummy_button = Menubutton(mBar, text='Dead Menu', underline=0)
 Dummy_button.pack(side=LEFT, padx='2m')
--- 210,214 ----
 
 
! def makeDisabledMenu():
 Dummy_button = Menubutton(mBar, text='Dead Menu', underline=0)
 Dummy_button.pack(side=LEFT, padx='2m')
***************
*** 234,238 ****
 NoMenu = makeDisabledMenu()
 
! # finally, install the buttons in the menu bar. 
 # This allows for scanning from one menubutton to the next.
 mBar.tk_menuBar(Command_button, Cascade_button, Checkbutton_button, Radiobutton_button, NoMenu)
--- 234,238 ----
 NoMenu = makeDisabledMenu()
 
! # finally, install the buttons in the menu bar.
 # This allows for scanning from one menubutton to the next.
 mBar.tk_menuBar(Command_button, Cascade_button, Checkbutton_button, Radiobutton_button, NoMenu)
***************
*** 243,250 ****
 
 root.mainloop()
- 
- 
- 
- 
- 
- 
--- 243,244 ----
Index: menu-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/menu-simple.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** menu-simple.py	21 Aug 1996 20:13:08 -0000	1.4
--- menu-simple.py	18 Jul 2004 06:09:09 -0000	1.5
***************
*** 1,15 ****
 from Tkinter import *
 
! # some vocabulary to keep from getting confused. This terminology 
! # is something I cooked up for this file, but follows the man pages 
 # pretty closely
! # 
! # 
! # 
 # This is a MENUBUTTON
 # V
 # +-------------+
 # | |
! # 
 # +------------++------------++------------+
 # | || || |
--- 1,15 ----
 from Tkinter import *
 
! # some vocabulary to keep from getting confused. This terminology
! # is something I cooked up for this file, but follows the man pages
 # pretty closely
! #
! #
! #
 # This is a MENUBUTTON
 # V
 # +-------------+
 # | |
! #
 # +------------++------------++------------+
 # | || || |
***************
*** 23,27 ****
 # | | MENU ENTRIES
 # | +---------------+
! # | Open Files > | file1 | 
 # | | file2 |
 # | | another file | <------ this cascading part is also a MENU
--- 23,27 ----
 # | | MENU ENTRIES
 # | +---------------+
! # | Open Files > | file1 |
 # | | file2 |
 # | | another file | <------ this cascading part is also a MENU
***************
*** 47,63 ****
 File_button.pack(side=LEFT, padx="1m")
 File_button.menu = Menu(File_button)
! 
! # add an item. The first param is a menu entry type, 
 # must be one of: "cascade", "checkbutton", "command", "radiobutton", "seperator"
 # see menu-demo-2.py for examples of use
! File_button.menu.add_command(label='New...', underline=0, 
! 				 command=new_file)
! 
! 
! File_button.menu.add_command(label='Open...', underline=0, 
! 				 command=open_file)
! 
! File_button.menu.add_command(label='Quit', underline=0, 
! 				 command='exit')
 
 # set up a pointer from the file menubutton back to the file menu
--- 47,63 ----
 File_button.pack(side=LEFT, padx="1m")
 File_button.menu = Menu(File_button)
! 
! # add an item. The first param is a menu entry type,
 # must be one of: "cascade", "checkbutton", "command", "radiobutton", "seperator"
 # see menu-demo-2.py for examples of use
! File_button.menu.add_command(label='New...', underline=0,
! command=new_file)
! 
! 
! File_button.menu.add_command(label='Open...', underline=0,
! command=open_file)
! 
! File_button.menu.add_command(label='Quit', underline=0,
! command='exit')
 
 # set up a pointer from the file menubutton back to the file menu
***************
*** 103,107 ****
 Edit_button = makeEditMenu()
 
! # finally, install the buttons in the menu bar. 
 # This allows for scanning from one menubutton to the next.
 mBar.tk_menuBar(File_button, Edit_button)
--- 103,107 ----
 Edit_button = makeEditMenu()
 
! # finally, install the buttons in the menu bar.
 # This allows for scanning from one menubutton to the next.
 mBar.tk_menuBar(File_button, Edit_button)
***************
*** 111,118 ****
 
 root.mainloop()
- 
- 
- 
- 
- 
- 
--- 111,112 ----
Index: not-what-you-might-think-1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/not-what-you-might-think-1.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** not-what-you-might-think-1.py	30 Jul 1996 18:56:55 -0000	1.2
--- not-what-you-might-think-1.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 5,23 ****
 def createWidgets(self):
 
! 	self.Gpanel = Frame(self, width='1i', height='1i',
! 			 background='green') 
! 	self.Gpanel.pack(side=LEFT)
 
! 	# a QUIT button
! 	self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', 
! 				 foreground='red',
! 				 command=self.quit)
! 	self.Gpanel.QUIT.pack(side=LEFT)
 
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 5,23 ----
 def createWidgets(self):
 
! self.Gpanel = Frame(self, width='1i', height='1i',
! background='green')
! self.Gpanel.pack(side=LEFT)
 
! # a QUIT button
! self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT',
! foreground='red',
! command=self.quit)
! self.Gpanel.QUIT.pack(side=LEFT)
 
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: not-what-you-might-think-2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/not-what-you-might-think-2.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** not-what-you-might-think-2.py	30 Jul 1996 18:56:57 -0000	1.2
--- not-what-you-might-think-2.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 5,25 ****
 def createWidgets(self):
 
! 	self.Gpanel = Frame(self, width='1i', height='1i',
! 			 background='green')
 
! 	# this line turns off the recalculation of geometry by masters.
! 	self.Gpanel.propagate(0)
 
! 	self.Gpanel.pack(side=LEFT)
 
! 	# a QUIT button
! 	self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', foreground='red',
! 				 command=self.quit)
! 	self.Gpanel.QUIT.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 5,25 ----
 def createWidgets(self):
 
! self.Gpanel = Frame(self, width='1i', height='1i',
! background='green')
 
! # this line turns off the recalculation of geometry by masters.
! self.Gpanel.propagate(0)
 
! self.Gpanel.pack(side=LEFT)
 
! # a QUIT button
! self.Gpanel.QUIT = Button(self.Gpanel, text='QUIT', foreground='red',
! command=self.quit)
! self.Gpanel.QUIT.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: packer-and-placer-together.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/packer-and-placer-together.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** packer-and-placer-together.py	30 Jul 1996 18:56:58 -0000	1.2
--- packer-and-placer-together.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,5 ****
 from Tkinter import *
 
! # This is a program that tests the placer geom manager in conjunction with 
 # the packer. The background (green) is packed, while the widget inside is placed
 
--- 1,5 ----
 from Tkinter import *
 
! # This is a program that tests the placer geom manager in conjunction with
 # the packer. The background (green) is packed, while the widget inside is placed
 
***************
*** 18,24 ****
 f = Frame(top, width=200, height=200, background='green')
 
! # note that we use a different manager here. 
! # This way, the top level frame widget resizes when the 
! # application window does. 
 f.pack(fill=BOTH, expand=1)
 
--- 18,24 ----
 f = Frame(top, width=200, height=200, background='green')
 
! # note that we use a different manager here.
! # This way, the top level frame widget resizes when the
! # application window does.
 f.pack(fill=BOTH, expand=1)
 
***************
*** 26,30 ****
 f.button = Button(f, foreground='red', text='amazing', command=dothis)
 
! # and place it so that the nw corner is 
 # 1/2 way along the top X edge of its' parent
 f.button.place(relx=0.5, rely=0.0, anchor=NW)
--- 26,30 ----
 f.button = Button(f, foreground='red', text='amazing', command=dothis)
 
! # and place it so that the nw corner is
 # 1/2 way along the top X edge of its' parent
 f.button.place(relx=0.5, rely=0.0, anchor=NW)
***************
*** 40,42 ****
 root.maxsize(1000, 1000)
 root.mainloop()
- 
--- 40,41 ----
Index: packer-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/packer-simple.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** packer-simple.py	30 Jul 1996 18:56:59 -0000	1.2
--- packer-simple.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 4,31 ****
 class Test(Frame):
 def printit(self):
! 	print self.hi_there["command"]
 
 def createWidgets(self):
! 	# a hello button
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	self.hi_there = Button(self, text='Hello', 
! 			 command=self.printit)
! 	self.hi_there.pack(side=LEFT)
 
! 	# note how Packer defaults to side=TOP
 
! 	self.guy2 = Button(self, text='button 2')
! 	self.guy2.pack()
 
! 	self.guy3 = Button(self, text='button 3')
! 	self.guy3.pack()
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 4,31 ----
 class Test(Frame):
 def printit(self):
! print self.hi_there["command"]
 
 def createWidgets(self):
! # a hello button
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
 
! self.hi_there = Button(self, text='Hello',
! command=self.printit)
! self.hi_there.pack(side=LEFT)
 
! # note how Packer defaults to side=TOP
 
! self.guy2 = Button(self, text='button 2')
! self.guy2.pack()
 
! self.guy3 = Button(self, text='button 3')
! self.guy3.pack()
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: placer-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/placer-simple.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** placer-simple.py	30 Jul 1996 18:57:01 -0000	1.2
--- placer-simple.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 16,20 ****
 f = Frame(top, width=200, height=200, background='green')
 
! # place it so the upper left hand corner of 
 # the frame is in the upper left corner of
 # the parent
--- 16,20 ----
 f = Frame(top, width=200, height=200, background='green')
 
! # place it so the upper left hand corner of
 # the frame is in the upper left corner of
 # the parent
***************
*** 24,28 ****
 f.button = Button(f, foreground='red', text='amazing', command=dothis)
 
! # and place it so that the nw corner is 
 # 1/2 way along the top X edge of its' parent
 f.button.place(relx=0.5, rely=0.0, anchor=NW)
--- 24,28 ----
 f.button = Button(f, foreground='red', text='amazing', command=dothis)
 
! # and place it so that the nw corner is
 # 1/2 way along the top X edge of its' parent
 f.button.place(relx=0.5, rely=0.0, anchor=NW)
***************
*** 38,40 ****
 root.maxsize(1000, 1000)
 root.mainloop()
- 
--- 38,39 ----
Index: pong-demo-1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/pong-demo-1.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pong-demo-1.py	12 Feb 2004 17:35:04 -0000	1.3
--- pong-demo-1.py	18 Jul 2004 06:09:09 -0000	1.4
***************
*** 6,51 ****
 class Pong(Frame):
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	## The playing field
! 	self.draw = Canvas(self, width="5i", height="5i")
 
! 	## The speed control for the ball
! 	self.speed = Scale(self, orient=HORIZONTAL, label="ball speed", 
! 			 from_=-100, to=100)
 
! 	self.speed.pack(side=BOTTOM, fill=X)
 
! 	# The ball
! 	self.ball = self.draw.create_oval("0i", "0i", "0.10i", "0.10i",
! 					 fill="red")
! 	self.x = 0.05
! 	self.y = 0.05
! 	self.velocity_x = 0.3
! 	self.velocity_y = 0.5
 
! 	self.draw.pack(side=LEFT)
 
 def moveBall(self, *args):
! 	if (self.x > 5.0) or (self.x < 0.0): 
! 	 self.velocity_x = -1.0 * self.velocity_x
! 	if (self.y > 5.0) or (self.y < 0.0): 
! 	 self.velocity_y = -1.0 * self.velocity_y
 
! 	deltax = (self.velocity_x * self.speed.get() / 100.0)
! 	deltay = (self.velocity_y * self.speed.get() / 100.0)
! 	self.x = self.x + deltax
! 	self.y = self.y + deltay
 
! 	self.draw.move(self.ball, "%ri" % deltax, "%ri" % deltay)
! 	self.after(10, self.moveBall)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
! 	self.after(10, self.moveBall)
 
 
--- 6,51 ----
 class Pong(Frame):
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
 
! ## The playing field
! self.draw = Canvas(self, width="5i", height="5i")
 
! ## The speed control for the ball
! self.speed = Scale(self, orient=HORIZONTAL, label="ball speed",
! from_=-100, to=100)
 
! self.speed.pack(side=BOTTOM, fill=X)
 
! # The ball
! self.ball = self.draw.create_oval("0i", "0i", "0.10i", "0.10i",
! fill="red")
! self.x = 0.05
! self.y = 0.05
! self.velocity_x = 0.3
! self.velocity_y = 0.5
 
! self.draw.pack(side=LEFT)
 
 def moveBall(self, *args):
! if (self.x > 5.0) or (self.x < 0.0):
! self.velocity_x = -1.0 * self.velocity_x
! if (self.y > 5.0) or (self.y < 0.0):
! self.velocity_y = -1.0 * self.velocity_y
 
! deltax = (self.velocity_x * self.speed.get() / 100.0)
! deltay = (self.velocity_y * self.speed.get() / 100.0)
! self.x = self.x + deltax
! self.y = self.y + deltay
 
! self.draw.move(self.ball, "%ri" % deltax, "%ri" % deltay)
! self.after(10, self.moveBall)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
! self.after(10, self.moveBall)
 
 
Index: printing-coords-of-items.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/printing-coords-of-items.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** printing-coords-of-items.py	30 Jul 1996 18:57:04 -0000	1.2
--- printing-coords-of-items.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 8,31 ****
 ###################################################################
 def mouseDown(self, event):
! 	# see if we're inside a dot. If we are, it
! 	# gets tagged as CURRENT for free by tk.
 
! 	if not event.widget.find_withtag(CURRENT):
! 	 # there is no dot here, so we can make one,
! 	 # and bind some interesting behavior to it.
! 	 # ------
! 	 # create a dot, and mark it as current
! 	 fred = self.draw.create_oval(
! 		event.x - 10, event.y -10, event.x +10, event.y + 10,
! 		fill="green")
! 	 self.draw.tag_bind(fred, "<Enter>", self.mouseEnter)
! 	 self.draw.tag_bind(fred, "<Leave>", self.mouseLeave)
! 	self.lastx = event.x
! 	self.lasty = event.y
 
 def mouseMove(self, event):
! 	self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty)
! 	self.lastx = event.x
! 	self.lasty = event.y
 
 ###################################################################
--- 8,31 ----
 ###################################################################
 def mouseDown(self, event):
! # see if we're inside a dot. If we are, it
! # gets tagged as CURRENT for free by tk.
 
! if not event.widget.find_withtag(CURRENT):
! # there is no dot here, so we can make one,
! # and bind some interesting behavior to it.
! # ------
! # create a dot, and mark it as current
! fred = self.draw.create_oval(
! event.x - 10, event.y -10, event.x +10, event.y + 10,
! fill="green")
! self.draw.tag_bind(fred, "<Enter>", self.mouseEnter)
! self.draw.tag_bind(fred, "<Leave>", self.mouseLeave)
! self.lastx = event.x
! self.lasty = event.y
 
 def mouseMove(self, event):
! self.draw.move(CURRENT, event.x - self.lastx, event.y - self.lasty)
! self.lastx = event.x
! self.lasty = event.y
 
 ###################################################################
***************
*** 34,64 ****
 def mouseEnter(self, event):
 # the "current" tag is applied to the object the cursor is over.
! 	# this happens automatically.
! 	self.draw.itemconfig(CURRENT, fill="red")
! 	print self.draw.coords(CURRENT)
! 	
 def mouseLeave(self, event):
! 	# the "current" tag is applied to the object the cursor is over.
! 	# this happens automatically.
! 	self.draw.itemconfig(CURRENT, fill="blue")
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red',
! 			 command=self.quit)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)	
! 	self.draw = Canvas(self, width="5i", height="5i")
! 	self.draw.pack(side=LEFT)
 
! 	Widget.bind(self.draw, "<1>", self.mouseDown)
! 	Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
 test.mainloop()
- 
- 
- 
--- 34,61 ----
 def mouseEnter(self, event):
 # the "current" tag is applied to the object the cursor is over.
! # this happens automatically.
! self.draw.itemconfig(CURRENT, fill="red")
! print self.draw.coords(CURRENT)
! 
 def mouseLeave(self, event):
! # the "current" tag is applied to the object the cursor is over.
! # this happens automatically.
! self.draw.itemconfig(CURRENT, fill="blue")
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
! self.draw = Canvas(self, width="5i", height="5i")
! self.draw.pack(side=LEFT)
 
! Widget.bind(self.draw, "<1>", self.mouseDown)
! Widget.bind(self.draw, "<B1-Motion>", self.mouseMove)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
 test.mainloop()
Index: radiobutton-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/radiobutton-simple.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** radiobutton-simple.py	30 Jul 1996 18:57:06 -0000	1.2
--- radiobutton-simple.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,9 ****
 from Tkinter import *
 
! # This is a demo program that shows how to 
! # create radio buttons and how to get other widgets to 
! # share the information in a radio button. 
! # 
! # There are other ways of doing this too, but 
 # the "variable" option of radiobuttons seems to be the easiest.
 #
--- 1,9 ----
 from Tkinter import *
 
! # This is a demo program that shows how to
! # create radio buttons and how to get other widgets to
! # share the information in a radio button.
! #
! # There are other ways of doing this too, but
 # the "variable" option of radiobuttons seems to be the easiest.
 #
***************
*** 13,60 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def createWidgets(self):
 
! 	self.flavor = StringVar()
! 	self.flavor.set("chocolate")
 
! 	self.radioframe = Frame(self)
! 	self.radioframe.pack()
 
! 	# 'text' is the label
! 	# 'variable' is the name of the variable that all these radio buttons share
! 	# 'value' is the value this variable takes on when the radio button is selected
! 	# 'anchor' makes the text appear left justified (default is centered. ick)
! 	self.radioframe.choc = Radiobutton(
! 	 self.radioframe, text="Chocolate Flavor", 
! 	 variable=self.flavor, value="chocolate",
! 	 anchor=W)
! 	self.radioframe.choc.pack(fill=X)
 
! 	self.radioframe.straw = Radiobutton(
! 	 self.radioframe, text="Strawberry Flavor", 
! 	 variable=self.flavor, value="strawberry",
! 	 anchor=W)
! 	self.radioframe.straw.pack(fill=X)
 
! 	self.radioframe.lemon = Radiobutton(
! 	 self.radioframe, text="Lemon Flavor", 
! 	 variable=self.flavor, value="lemon", 
! 	 anchor=W)
! 	self.radioframe.lemon.pack(fill=X)
! 	
! 	# this is a text entry that lets you type in the name of a flavor too.
! 	self.entry = Entry(self, textvariable=self.flavor)
! 	self.entry.pack(fill=X)
! 	self.QUIT = Button(self, text='QUIT', foreground='red',
! 			 command=self.quit)
! 	self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 13,60 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def createWidgets(self):
 
! self.flavor = StringVar()
! self.flavor.set("chocolate")
 
! self.radioframe = Frame(self)
! self.radioframe.pack()
 
! # 'text' is the label
! # 'variable' is the name of the variable that all these radio buttons share
! # 'value' is the value this variable takes on when the radio button is selected
! # 'anchor' makes the text appear left justified (default is centered. ick)
! self.radioframe.choc = Radiobutton(
! self.radioframe, text="Chocolate Flavor",
! variable=self.flavor, value="chocolate",
! anchor=W)
! self.radioframe.choc.pack(fill=X)
 
! self.radioframe.straw = Radiobutton(
! self.radioframe, text="Strawberry Flavor",
! variable=self.flavor, value="strawberry",
! anchor=W)
! self.radioframe.straw.pack(fill=X)
 
! self.radioframe.lemon = Radiobutton(
! self.radioframe, text="Lemon Flavor",
! variable=self.flavor, value="lemon",
! anchor=W)
! self.radioframe.lemon.pack(fill=X)
! 
! # this is a text entry that lets you type in the name of a flavor too.
! self.entry = Entry(self, textvariable=self.flavor)
! self.entry.pack(fill=X)
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=BOTTOM, fill=BOTH)
 
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: rubber-band-box-demo-1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/rubber-band-box-demo-1.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rubber-band-box-demo-1.py	30 Jul 1996 18:57:07 -0000	1.2
--- rubber-band-box-demo-1.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 3,55 ****
 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)
 
 
--- 3,55 ----
 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)
 
 
Index: rubber-line-demo-1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/rubber-line-demo-1.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rubber-line-demo-1.py	30 Jul 1996 18:57:09 -0000	1.2
--- rubber-line-demo-1.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 3,49 ****
 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.rubberbandLine)
! 	 self.rubberbandLine = self.canvasObject.create_line(
! 		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 __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.rubberbandLine = None
! 	Widget.bind(self.canvasObject, "<Button-1>", self.mouseDown)
! 	Widget.bind(self.canvasObject, "<Button1-Motion>", self.mouseMotion)
! 	
 
 test = Test()
--- 3,49 ----
 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.rubberbandLine)
! self.rubberbandLine = self.canvasObject.create_line(
! 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 __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.rubberbandLine = None
! Widget.bind(self.canvasObject, "<Button-1>", self.mouseDown)
! Widget.bind(self.canvasObject, "<Button1-Motion>", self.mouseMotion)
! 
 
 test = Test()
Index: slider-demo-1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/slider-demo-1.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** slider-demo-1.py	30 Jul 1996 18:57:10 -0000	1.2
--- slider-demo-1.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 6,35 ****
 class Test(Frame):
 def print_value(self, val):
! 	print "slider now at", val
 
! def reset(self): 
! 	self.slider.set(0)
 
 def createWidgets(self):
! 	self.slider = Scale(self, from_=0, to=100, 
! 			 orient=HORIZONTAL, 
! 			 length="3i", 
! 			 label="happy slider", 
! 			 command=self.print_value)
 
! 	self.reset = Button(self, text='reset slider', 
! 			 command=self.reset)
 
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
 
! 	self.slider.pack(side=LEFT)
! 	self.reset.pack(side=LEFT)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 6,35 ----
 class Test(Frame):
 def print_value(self, val):
! print "slider now at", val
 
! def reset(self):
! self.slider.set(0)
 
 def createWidgets(self):
! self.slider = Scale(self, from_=0, to=100,
! orient=HORIZONTAL,
! length="3i",
! label="happy slider",
! command=self.print_value)
 
! self.reset = Button(self, text='reset slider',
! command=self.reset)
 
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
 
! self.slider.pack(side=LEFT)
! self.reset.pack(side=LEFT)
! self.QUIT.pack(side=LEFT, fill=BOTH)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: subclass-existing-widgets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/subclass-existing-widgets.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** subclass-existing-widgets.py	30 Jul 1996 18:57:12 -0000	1.2
--- subclass-existing-widgets.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 6,12 ****
 class New_Button(Button):
 def callback(self):
! 	print self.counter
! 	self.counter = self.counter + 1
! 
 def createWidgets(top):
 f = Frame(top)
--- 6,12 ----
 class New_Button(Button):
 def callback(self):
! print self.counter
! self.counter = self.counter + 1
! 
 def createWidgets(top):
 f = Frame(top)
***************
*** 27,29 ****
 createWidgets(root)
 root.mainloop()
- 
--- 27,28 ----
Index: two-radio-groups.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/two-radio-groups.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** two-radio-groups.py	30 Jul 1996 18:57:13 -0000	1.2
--- two-radio-groups.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 1,43 ****
 from Tkinter import *
 
! #	The way to think about this is that each radio button menu
! #	controls a different variable -- clicking on one of the
! #	mutually exclusive choices in a radiobutton assigns some value
! #	to an application variable you provide. When you define a
! #	radiobutton menu choice, you have the option of specifying the
! #	name of a varaible and value to assign to that variable when
! #	that choice is selected. This clever mechanism relieves you,
! #	the programmer, from having to write a dumb callback that
! #	probably wouldn't have done anything more than an assignment
! #	anyway. The Tkinter options for this follow their Tk
! #	counterparts: 
! #	{"variable" : my_flavor_variable, "value" : "strawberry"}
 # where my_flavor_variable is an instance of one of the
 # subclasses of Variable, provided in Tkinter.py (there is
! #	StringVar(), IntVar(), DoubleVar() and BooleanVar() to choose
! #	from) 
 
 
 
 def makePoliticalParties(var):
! # make menu button 
! Radiobutton_button = Menubutton(mBar, text='Political Party', 
! 				 underline=0)
 Radiobutton_button.pack(side=LEFT, padx='2m')
! 
 # the primary pulldown
 Radiobutton_button.menu = Menu(Radiobutton_button)
 
! Radiobutton_button.menu.add_radiobutton(label='Republican', 
! 					 variable=var, value=1)
 
! Radiobutton_button.menu.add('radiobutton', {'label': 'Democrat', 
! 						'variable' : var, 
! 						'value' : 2})
 
- Radiobutton_button.menu.add('radiobutton', {'label': 'Libertarian', 
- 						'variable' : var, 
- 						'value' : 3})
- 
 var.set(2)
 
--- 1,43 ----
 from Tkinter import *
 
! # The way to think about this is that each radio button menu
! # controls a different variable -- clicking on one of the
! # mutually exclusive choices in a radiobutton assigns some value
! # to an application variable you provide. When you define a
! # radiobutton menu choice, you have the option of specifying the
! # name of a varaible and value to assign to that variable when
! # that choice is selected. This clever mechanism relieves you,
! # the programmer, from having to write a dumb callback that
! # probably wouldn't have done anything more than an assignment
! # anyway. The Tkinter options for this follow their Tk
! # counterparts:
! # {"variable" : my_flavor_variable, "value" : "strawberry"}
 # where my_flavor_variable is an instance of one of the
 # subclasses of Variable, provided in Tkinter.py (there is
! # StringVar(), IntVar(), DoubleVar() and BooleanVar() to choose
! # from)
 
 
 
 def makePoliticalParties(var):
! # make menu button
! Radiobutton_button = Menubutton(mBar, text='Political Party',
! underline=0)
 Radiobutton_button.pack(side=LEFT, padx='2m')
! 
 # the primary pulldown
 Radiobutton_button.menu = Menu(Radiobutton_button)
 
! Radiobutton_button.menu.add_radiobutton(label='Republican',
! variable=var, value=1)
 
! Radiobutton_button.menu.add('radiobutton', {'label': 'Democrat',
! 'variable' : var,
! 'value' : 2})
! 
! Radiobutton_button.menu.add('radiobutton', {'label': 'Libertarian',
! 'variable' : var,
! 'value' : 3})
 
 var.set(2)
 
***************
*** 49,55 ****
 
 def makeFlavors(var):
! # make menu button 
! Radiobutton_button = Menubutton(mBar, text='Flavors', 
! 				 underline=0)
 Radiobutton_button.pack(side=LEFT, padx='2m')
 
--- 49,55 ----
 
 def makeFlavors(var):
! # make menu button
! Radiobutton_button = Menubutton(mBar, text='Flavors',
! underline=0)
 Radiobutton_button.pack(side=LEFT, padx='2m')
 
***************
*** 58,68 ****
 
 Radiobutton_button.menu.add_radiobutton(label='Strawberry',
! 					 variable=var, value='Strawberry')
 
 Radiobutton_button.menu.add_radiobutton(label='Chocolate',
! 					 variable=var, value='Chocolate')
 
 Radiobutton_button.menu.add_radiobutton(label='Rocky Road',
! 					 variable=var, value='Rocky Road')
 
 # choose a default
--- 58,68 ----
 
 Radiobutton_button.menu.add_radiobutton(label='Strawberry',
! variable=var, value='Strawberry')
 
 Radiobutton_button.menu.add_radiobutton(label='Chocolate',
! variable=var, value='Chocolate')
 
 Radiobutton_button.menu.add_radiobutton(label='Rocky Road',
! variable=var, value='Rocky Road')
 
 # choose a default
***************
*** 89,93 ****
 mBar.pack(fill=X)
 
! # make two application variables, 
 # one to control each radio button set
 party = IntVar()
--- 89,93 ----
 mBar.pack(fill=X)
 
! # make two application variables,
 # one to control each radio button set
 party = IntVar()
***************
*** 97,106 ****
 Radiobutton_button2 = makeFlavors(flavor)
 
! # finally, install the buttons in the menu bar. 
 # This allows for scanning from one menubutton to the next.
 mBar.tk_menuBar(Radiobutton_button, Radiobutton_button2)
 
 b = Button(root, text="print party and flavor", foreground="red",
! 	 command=printStuff)
 b.pack(side=TOP)
 
--- 97,106 ----
 Radiobutton_button2 = makeFlavors(flavor)
 
! # finally, install the buttons in the menu bar.
 # This allows for scanning from one menubutton to the next.
 mBar.tk_menuBar(Radiobutton_button, Radiobutton_button2)
 
 b = Button(root, text="print party and flavor", foreground="red",
! command=printStuff)
 b.pack(side=TOP)
 
Index: window-creation-more.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/window-creation-more.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** window-creation-more.py	30 Jul 1996 18:57:15 -0000	1.2
--- window-creation-more.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 6,34 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def makeWindow(self):
! 	fred = Toplevel()
! 	fred.label = Button(fred,
! 			 text="This is window number %d." % self.windownum, 
! 			 command=self.makeWindow)
! 	fred.label.pack()
! 	self.windownum = self.windownum + 1
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	# a hello button
! 	self.hi_there = Button(self, text='Make a New Window', 
! 			 command=self.makeWindow)
! 	self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.windownum = 0 
! 	self.createWidgets()
 
 test = Test()
--- 6,34 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def makeWindow(self):
! fred = Toplevel()
! fred.label = Button(fred,
! text="This is window number %d." % self.windownum,
! command=self.makeWindow)
! fred.label.pack()
! self.windownum = self.windownum + 1
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
! self.QUIT.pack(side=LEFT, fill=BOTH)
 
! # a hello button
! self.hi_there = Button(self, text='Make a New Window',
! command=self.makeWindow)
! self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.windownum = 0
! self.createWidgets()
 
 test = Test()
Index: window-creation-simple.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/window-creation-simple.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** window-creation-simple.py	30 Jul 1996 18:57:17 -0000	1.2
--- window-creation-simple.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 5,30 ****
 class Test(Frame):
 def printit(self):
! 	print "hi"
 
 def makeWindow(self):
! 	fred = Toplevel()
! 	fred.label = Label(fred, text="Here's a new window")
! 	fred.label.pack()
 
 def createWidgets(self):
! 	self.QUIT = Button(self, text='QUIT', foreground='red', 
! 			 command=self.quit)
! 	
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	# a hello button
! 	self.hi_there = Button(self, text='Make a New Window', 
! 			 command=self.makeWindow)
! 	self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 5,30 ----
 class Test(Frame):
 def printit(self):
! print "hi"
 
 def makeWindow(self):
! fred = Toplevel()
! fred.label = Label(fred, text="Here's a new window")
! fred.label.pack()
 
 def createWidgets(self):
! self.QUIT = Button(self, text='QUIT', foreground='red',
! command=self.quit)
 
! self.QUIT.pack(side=LEFT, fill=BOTH)
! 
! # a hello button
! self.hi_there = Button(self, text='Make a New Window',
! command=self.makeWindow)
! self.hi_there.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()
Index: window-creation-w-location.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/matt/window-creation-w-location.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** window-creation-w-location.py	8 Apr 1999 15:18:12 -0000	1.3
--- window-creation-w-location.py	18 Jul 2004 06:09:09 -0000	1.4
***************
*** 18,44 ****
 class Test(Frame):
 def makeWindow(self, *args):
! 	fred = Toplevel()
 
! 	fred.label = Canvas (fred, width="2i", height="2i")
 
! 	fred.label.create_line("0", "0", "2i", "2i")
! 	fred.label.create_line("0", "2i", "2i", "0")
! 	fred.label.pack()
 
! 	##centerWindow(fred, self.master)
 
 def createWidgets(self):
! 	self.QUIT = QuitButton(self)
! 	self.QUIT.pack(side=LEFT, fill=BOTH)
 
! 	self.makeWindow = Button(self, text='Make a New Window',
! 				 width=50, height=20,
! 				 command=self.makeWindow)
! 	self.makeWindow.pack(side=LEFT)
 
 def __init__(self, master=None):
! 	Frame.__init__(self, master)
! 	Pack.config(self)
! 	self.createWidgets()
 
 test = Test()
--- 18,44 ----
 class Test(Frame):
 def makeWindow(self, *args):
! fred = Toplevel()
 
! fred.label = Canvas (fred, width="2i", height="2i")
 
! fred.label.create_line("0", "0", "2i", "2i")
! fred.label.create_line("0", "2i", "2i", "0")
! fred.label.pack()
 
! ##centerWindow(fred, self.master)
 
 def createWidgets(self):
! self.QUIT = QuitButton(self)
! self.QUIT.pack(side=LEFT, fill=BOTH)
 
! self.makeWindow = Button(self, text='Make a New Window',
! width=50, height=20,
! command=self.makeWindow)
! self.makeWindow.pack(side=LEFT)
 
 def __init__(self, master=None):
! Frame.__init__(self, master)
! Pack.config(self)
! self.createWidgets()
 
 test = Test()


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /