[Python-checkins] python/dist/src/Demo/tkinter/guido AttrDialog.py, 1.8, 1.9 ManPage.py, 1.9, 1.10 MimeViewer.py, 1.3, 1.4 ShellWindow.py, 1.3, 1.4 canvasevents.py, 1.1, 1.2 dialog.py, 1.6, 1.7 electrons.py, 1.9, 1.10 hanoi.py, 1.3, 1.4 hello.py, 1.1, 1.2 kill.py, 1.5, 1.6 listtree.py, 1.3, 1.4 mbox.py, 1.5, 1.6 newmenubardemo.py, 1.2, 1.3 paint.py, 1.1, 1.2 rmt.py, 1.6, 1.7 solitaire.py, 1.5, 1.6 sortvisu.py, 1.1, 1.2 ss1.py, 1.4, 1.5 svkill.py, 1.6, 1.7 tkman.py, 1.10, 1.11 wish.py, 1.4, 1.5

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


Update of /cvsroot/python/python/dist/src/Demo/tkinter/guido
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30561/guido

Modified Files:
	AttrDialog.py ManPage.py MimeViewer.py ShellWindow.py 
	canvasevents.py dialog.py electrons.py hanoi.py hello.py 
	kill.py listtree.py mbox.py newmenubardemo.py paint.py rmt.py 
	solitaire.py sortvisu.py ss1.py svkill.py tkman.py wish.py 
Log Message:
Whitespace normalization, via reindent.py.


Index: AttrDialog.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/AttrDialog.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** AttrDialog.py	8 Oct 1998 15:24:01 -0000	1.8
--- AttrDialog.py	18 Jul 2004 06:09:08 -0000	1.9
***************
*** 17,452 ****
  class Option:
  
! 	varclass = StringVar		# May be overridden
  
! 	def __init__(self, dialog, option):
! 		self.dialog = dialog
! 		self.option = option
! 		self.master = dialog.top
! 		self.default, self.klass = dialog.options[option]
! 		self.var = self.varclass(self.master)
! 		self.frame = Frame(self.master)
! 		self.frame.pack(fill=X)
! 		self.label = Label(self.frame, text=(option + ":"))
! 		self.label.pack(side=LEFT)
! 		self.update()
! 		self.addoption()
  
! 	def refresh(self):
! 		self.dialog.refresh()
! 		self.update()
  
! 	def update(self):
! 		try:
! 			self.current = self.dialog.current[self.option]
! 		except KeyError:
! 			self.current = self.default
! 		self.var.set(self.current)
  
! 	def set(self, e=None):		# Should be overridden
! 		pass
  
  class BooleanOption(Option):
  
! 	varclass = BooleanVar
  
! 	def addoption(self):
! 		self.button = Checkbutton(self.frame,
! 					 text='on/off',
! 					 onvalue=1,
! 					 offvalue=0,
! 					 variable=self.var,
! 					 relief=RAISED,
! 					 borderwidth=2,
! 					 command=self.set)
! 		self.button.pack(side=RIGHT)
  
  class EnumOption(Option):
  
! 	def addoption(self):
! 		self.button = Menubutton(self.frame,
! 					 textvariable=self.var,
! 					 relief=RAISED, borderwidth=2)
! 		self.button.pack(side=RIGHT)
! 		self.menu = Menu(self.button)
! 		self.button['menu'] = self.menu
! 		for v in self.dialog.classes[self.klass]:
! 			self.menu.add_radiobutton(
! 			    label=v,
! 			    variable=self.var,
! 			    value=v,
! 			    command=self.set)
  
  class StringOption(Option):
  
! 	def addoption(self):
! 		self.entry = Entry(self.frame,
! 				   textvariable=self.var,
! 				   width=10,
! 				   relief=SUNKEN,
! 				   borderwidth=2)
! 		self.entry.pack(side=RIGHT, fill=X, expand=1)
! 		self.entry.bind('<Return>', self.set)
  
  class ReadonlyOption(Option):
  
! 	def addoption(self):
! 		self.label = Label(self.frame, textvariable=self.var,
! 				   anchor=E)
! 		self.label.pack(side=RIGHT)
  
  class Dialog:
  
! 	def __init__(self, master):
! 		self.master = master
! 		self.fixclasses()
! 		self.refresh()
! 		self.top = Toplevel(self.master)
! 		self.top.title(self.__class__.__name__)
! 		self.top.minsize(1, 1)
! 		self.addchoices()
  
! 	def refresh(self): pass		# Must override
  
! 	def fixclasses(self): pass	# May override
  
! 	def addchoices(self):
! 		self.choices = {}
! 		list = []
! 		for k, dc in self.options.items():
! 			list.append((k, dc))
! 		list.sort()
! 		for k, (d, c) in list:
! 			try:
! 				cl = self.classes[c]
! 			except KeyError:
! 				cl = 'unknown'
! 			if type(cl) == TupleType:
! 				cl = self.enumoption
! 			elif cl == 'boolean':
! 				cl = self.booleanoption
! 			elif cl == 'readonly':
! 				cl = self.readonlyoption
! 			else:
! 				cl = self.stringoption
! 			self.choices[k] = cl(self, k)
  
! 	# Must override:
! 	options = {}
! 	classes = {}
  
! 	# May override:
! 	booleanoption = BooleanOption
! 	stringoption = StringOption
! 	enumoption = EnumOption
! 	readonlyoption = ReadonlyOption
  
  class PackDialog(Dialog):
  
! 	def __init__(self, widget):
! 		self.widget = widget
! 		Dialog.__init__(self, widget)
  
! 	def refresh(self):
! 		self.current = self.widget.info()
! 		self.current['.class'] = self.widget.winfo_class()
! 		self.current['.name'] = self.widget._w
  
! 	class packoption: # Mix-in class
! 		def set(self, e=None):
! 			self.current = self.var.get()
! 			try:
! 				apply(self.dialog.widget.pack, (),
! 				      {self.option: self.current})
! 			except TclError, msg:
! 				print msg
! 				self.refresh()
  
! 	class booleanoption(packoption, BooleanOption): pass
! 	class enumoption(packoption, EnumOption): pass
! 	class stringoption(packoption, StringOption): pass
! 	class readonlyoption(packoption, ReadonlyOption): pass
  
! 	options = {
! 		'.class': (None, 'Class'),
! 		'.name': (None, 'Name'),
! 		'after': (None, 'Widget'),
! 		'anchor': ('center', 'Anchor'),
! 		'before': (None, 'Widget'),
! 		'expand': ('no', 'Boolean'),
! 		'fill': ('none', 'Fill'),
! 		'in': (None, 'Widget'),
! 		'ipadx': (0, 'Pad'),
! 		'ipady': (0, 'Pad'),
! 		'padx': (0, 'Pad'),
! 		'pady': (0, 'Pad'),
! 		'side': ('top', 'Side'),
! 		}
  
! 	classes = {
! 		'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER),
! 		'Boolean': 'boolean',
! 		'Class': 'readonly',
! 		'Expand': 'boolean',
! 		'Fill': (NONE, X, Y, BOTH),
! 		'Name': 'readonly',
! 		'Pad': 'pixel',
! 		'Side': (TOP, RIGHT, BOTTOM, LEFT),
! 		'Widget': 'readonly',
! 		}
  
  class RemotePackDialog(PackDialog):
  
! 	def __init__(self, master, app, widget):
! 		self.master = master
! 		self.app = app
! 		self.widget = widget
! 		self.refresh()
! 		self.top = Toplevel(self.master)
! 		self.top.title(self.app + ' PackDialog')
! 		self.top.minsize(1, 1)
! 		self.addchoices()
  
! 	def refresh(self):
! 		try:
! 			words = self.master.tk.splitlist(
! 				self.master.send(self.app,
! 						 'pack',
! 						 'info',
! 						 self.widget))
! 		except TclError, msg:
! 			print msg
! 			return
! 		dict = {}
! 		for i in range(0, len(words), 2):
! 			key = words[i][1:]
! 			value = words[i+1]
! 			dict[key] = value
! 		dict['.class'] = self.master.send(self.app,
! 						  'winfo',
! 						  'class',
! 						  self.widget)
! 		dict['.name'] = self.widget
! 		self.current = dict
  
! 	class remotepackoption: # Mix-in class
! 		def set(self, e=None):
! 			self.current = self.var.get()
! 			try:
! 				self.dialog.master.send(
! 					self.dialog.app,
! 					'pack',
! 					'config',
! 					self.dialog.widget,
! 					'-'+self.option,
! 					self.dialog.master.tk.merge(
! 						self.current))
! 			except TclError, msg:
! 				print msg
! 				self.refresh()
  
! 	class booleanoption(remotepackoption, BooleanOption): pass
! 	class enumoption(remotepackoption, EnumOption): pass
! 	class stringoption(remotepackoption, StringOption): pass
! 	class readonlyoption(remotepackoption, ReadonlyOption): pass
  
  class WidgetDialog(Dialog):
  
! 	def __init__(self, widget):
! 		self.widget = widget
! 		self.klass = widget.winfo_class()
! 		Dialog.__init__(self, widget)
  
! 	def fixclasses(self):
! 		if self.addclasses.has_key(self.klass):
! 			classes = {}
! 			for c in (self.classes,
! 				  self.addclasses[self.klass]):
! 				for k in c.keys():
! 					classes[k] = c[k]
! 			self.classes = classes
  
! 	def refresh(self):
! 		self.configuration = self.widget.config()
! 		self.update()
! 		self.current['.class'] = self.widget.winfo_class()
! 		self.current['.name'] = self.widget._w
  
! 	def update(self):
! 		self.current = {}
! 		self.options = {}
! 		for k, v in self.configuration.items():
! 			if len(v) > 4:
! 				self.current[k] = v[4]
! 				self.options[k] = v[3], v[2] # default, klass
! 		self.options['.class'] = (None, 'Class')
! 		self.options['.name'] = (None, 'Name')
  
! 	class widgetoption: # Mix-in class
! 		def set(self, e=None):
! 			self.current = self.var.get()
! 			try:
! 				self.dialog.widget[self.option] = self.current
! 			except TclError, msg:
! 				print msg
! 				self.refresh()
  
! 	class booleanoption(widgetoption, BooleanOption): pass
! 	class enumoption(widgetoption, EnumOption): pass
! 	class stringoption(widgetoption, StringOption): pass
! 	class readonlyoption(widgetoption, ReadonlyOption): pass
  
! 	# Universal classes
! 	classes = {
! 		'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER),
! 		'Aspect': 'integer',
! 		'Background': 'color',
! 		'Bitmap': 'bitmap',
! 		'BorderWidth': 'pixel',
! 		'Class': 'readonly',
! 		'CloseEnough': 'double',
! 		'Command': 'command',
! 		'Confine': 'boolean',
! 		'Cursor': 'cursor',
! 		'CursorWidth': 'pixel',
! 		'DisabledForeground': 'color',
! 		'ExportSelection': 'boolean',
! 		'Font': 'font',
! 		'Foreground': 'color',
! 		'From': 'integer',
! 		'Geometry': 'geometry',
! 		'Height': 'pixel',
! 		'InsertWidth': 'time',
! 		'Justify': (LEFT, CENTER, RIGHT),
! 		'Label': 'string',
! 		'Length': 'pixel',
! 		'MenuName': 'widget',
! 		'Name': 'readonly',
! 		'OffTime': 'time',
! 		'OnTime': 'time',
! 		'Orient': (HORIZONTAL, VERTICAL),
! 		'Pad': 'pixel',
! 		'Relief': (RAISED, SUNKEN, FLAT, RIDGE, GROOVE),
! 		'RepeatDelay': 'time',
! 		'RepeatInterval': 'time',
! 		'ScrollCommand': 'command',
! 		'ScrollIncrement': 'pixel',
! 		'ScrollRegion': 'rectangle',
! 		'ShowValue': 'boolean',
! 		'SetGrid': 'boolean',
! 		'Sliderforeground': 'color',
! 		'SliderLength': 'pixel',
! 		'Text': 'string',
! 		'TickInterval': 'integer',
! 		'To': 'integer',
! 		'Underline': 'index',
! 		'Variable': 'variable',
! 		'Value': 'string',
! 		'Width': 'pixel',
! 		'Wrap': (NONE, CHAR, WORD),
! 		}
  
! 	# Classes that (may) differ per widget type
! 	_tristate = {'State': (NORMAL, ACTIVE, DISABLED)}
! 	_bistate = {'State': (NORMAL, DISABLED)}
! 	addclasses = {
! 		'Button': _tristate,
! 		'Radiobutton': _tristate,
! 		'Checkbutton': _tristate,
! 		'Entry': _bistate,
! 		'Text': _bistate,
! 		'Menubutton': _tristate,
! 		'Slider': _bistate,
! 		}
  
  class RemoteWidgetDialog(WidgetDialog):
  
! 	def __init__(self, master, app, widget):
! 		self.app = app
! 		self.widget = widget
! 		self.klass = master.send(self.app,
! 					 'winfo',
! 					 'class',
! 					 self.widget)
! 		Dialog.__init__(self, master)
  
! 	def refresh(self):
! 		try:
! 			items = self.master.tk.splitlist(
! 				self.master.send(self.app,
! 						 self.widget,
! 						 'config'))
! 		except TclError, msg:
! 			print msg
! 			return
! 		dict = {}
! 		for item in items:
! 			words = self.master.tk.splitlist(item)
! 			key = words[0][1:]
! 			value = (key,) + words[1:]
! 			dict[key] = value
! 		self.configuration = dict
! 		self.update()
! 		self.current['.class'] = self.klass
! 		self.current['.name'] = self.widget
  
! 	class remotewidgetoption: # Mix-in class
! 		def set(self, e=None):
! 			self.current = self.var.get()
! 			try:
! 				self.dialog.master.send(
! 					self.dialog.app,
! 					self.dialog.widget,
! 					'config',
! 					'-'+self.option,
! 					self.current)
! 			except TclError, msg:
! 				print msg
! 				self.refresh()
  
! 	class booleanoption(remotewidgetoption, BooleanOption): pass
! 	class enumoption(remotewidgetoption, EnumOption): pass
! 	class stringoption(remotewidgetoption, StringOption): pass
! 	class readonlyoption(remotewidgetoption, ReadonlyOption): pass
  
  def test():
! 	import sys
! 	root = Tk()
! 	root.minsize(1, 1)
! 	if sys.argv[1:]:
! 		remotetest(root, sys.argv[1])
! 	else:
! 		frame = Frame(root, name='frame')
! 		frame.pack(expand=1, fill=BOTH)
! 		button = Button(frame, name='button', text='button')
! 		button.pack(expand=1)
! 		canvas = Canvas(frame, name='canvas')
! 		canvas.pack()
! 		fpd = PackDialog(frame)
! 		fwd = WidgetDialog(frame)
! 		bpd = PackDialog(button)
! 		bwd = WidgetDialog(button)
! 		cpd = PackDialog(canvas)
! 		cwd = WidgetDialog(canvas)
! 	root.mainloop()
  
  def remotetest(root, app):
! 	from listtree import listtree
! 	list = listtree(root, app)
! 	list.bind('<Any-Double-1>', opendialogs)
! 	list.app = app			# Pass it on to handler
  
  def opendialogs(e):
! 	import string
! 	list = e.widget
! 	sel = list.curselection()
! 	for i in sel:
! 		item = list.get(i)
! 		widget = string.split(item)[0]
! 		RemoteWidgetDialog(list, list.app, widget)
! 		if widget == '.': continue
! 		try:
! 			RemotePackDialog(list, list.app, widget)
! 		except TclError, msg:
! 			print msg
  
  test()
--- 17,452 ----
  class Option:
  
!     varclass = StringVar            # May be overridden
  
!     def __init__(self, dialog, option):
!         self.dialog = dialog
!         self.option = option
!         self.master = dialog.top
!         self.default, self.klass = dialog.options[option]
!         self.var = self.varclass(self.master)
!         self.frame = Frame(self.master)
!         self.frame.pack(fill=X)
!         self.label = Label(self.frame, text=(option + ":"))
!         self.label.pack(side=LEFT)
!         self.update()
!         self.addoption()
  
!     def refresh(self):
!         self.dialog.refresh()
!         self.update()
  
!     def update(self):
!         try:
!             self.current = self.dialog.current[self.option]
!         except KeyError:
!             self.current = self.default
!         self.var.set(self.current)
  
!     def set(self, e=None):          # Should be overridden
!         pass
  
  class BooleanOption(Option):
  
!     varclass = BooleanVar
  
!     def addoption(self):
!         self.button = Checkbutton(self.frame,
!                                  text='on/off',
!                                  onvalue=1,
!                                  offvalue=0,
!                                  variable=self.var,
!                                  relief=RAISED,
!                                  borderwidth=2,
!                                  command=self.set)
!         self.button.pack(side=RIGHT)
  
  class EnumOption(Option):
  
!     def addoption(self):
!         self.button = Menubutton(self.frame,
!                                  textvariable=self.var,
!                                  relief=RAISED, borderwidth=2)
!         self.button.pack(side=RIGHT)
!         self.menu = Menu(self.button)
!         self.button['menu'] = self.menu
!         for v in self.dialog.classes[self.klass]:
!             self.menu.add_radiobutton(
!                 label=v,
!                 variable=self.var,
!                 value=v,
!                 command=self.set)
  
  class StringOption(Option):
  
!     def addoption(self):
!         self.entry = Entry(self.frame,
!                            textvariable=self.var,
!                            width=10,
!                            relief=SUNKEN,
!                            borderwidth=2)
!         self.entry.pack(side=RIGHT, fill=X, expand=1)
!         self.entry.bind('<Return>', self.set)
  
  class ReadonlyOption(Option):
  
!     def addoption(self):
!         self.label = Label(self.frame, textvariable=self.var,
!                            anchor=E)
!         self.label.pack(side=RIGHT)
  
  class Dialog:
  
!     def __init__(self, master):
!         self.master = master
!         self.fixclasses()
!         self.refresh()
!         self.top = Toplevel(self.master)
!         self.top.title(self.__class__.__name__)
!         self.top.minsize(1, 1)
!         self.addchoices()
  
!     def refresh(self): pass         # Must override
  
!     def fixclasses(self): pass      # May override
  
!     def addchoices(self):
!         self.choices = {}
!         list = []
!         for k, dc in self.options.items():
!             list.append((k, dc))
!         list.sort()
!         for k, (d, c) in list:
!             try:
!                 cl = self.classes[c]
!             except KeyError:
!                 cl = 'unknown'
!             if type(cl) == TupleType:
!                 cl = self.enumoption
!             elif cl == 'boolean':
!                 cl = self.booleanoption
!             elif cl == 'readonly':
!                 cl = self.readonlyoption
!             else:
!                 cl = self.stringoption
!             self.choices[k] = cl(self, k)
  
!     # Must override:
!     options = {}
!     classes = {}
  
!     # May override:
!     booleanoption = BooleanOption
!     stringoption = StringOption
!     enumoption = EnumOption
!     readonlyoption = ReadonlyOption
  
  class PackDialog(Dialog):
  
!     def __init__(self, widget):
!         self.widget = widget
!         Dialog.__init__(self, widget)
  
!     def refresh(self):
!         self.current = self.widget.info()
!         self.current['.class'] = self.widget.winfo_class()
!         self.current['.name'] = self.widget._w
  
!     class packoption: # Mix-in class
!         def set(self, e=None):
!             self.current = self.var.get()
!             try:
!                 apply(self.dialog.widget.pack, (),
!                       {self.option: self.current})
!             except TclError, msg:
!                 print msg
!                 self.refresh()
  
!     class booleanoption(packoption, BooleanOption): pass
!     class enumoption(packoption, EnumOption): pass
!     class stringoption(packoption, StringOption): pass
!     class readonlyoption(packoption, ReadonlyOption): pass
  
!     options = {
!             '.class': (None, 'Class'),
!             '.name': (None, 'Name'),
!             'after': (None, 'Widget'),
!             'anchor': ('center', 'Anchor'),
!             'before': (None, 'Widget'),
!             'expand': ('no', 'Boolean'),
!             'fill': ('none', 'Fill'),
!             'in': (None, 'Widget'),
!             'ipadx': (0, 'Pad'),
!             'ipady': (0, 'Pad'),
!             'padx': (0, 'Pad'),
!             'pady': (0, 'Pad'),
!             'side': ('top', 'Side'),
!             }
  
!     classes = {
!             'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER),
!             'Boolean': 'boolean',
!             'Class': 'readonly',
!             'Expand': 'boolean',
!             'Fill': (NONE, X, Y, BOTH),
!             'Name': 'readonly',
!             'Pad': 'pixel',
!             'Side': (TOP, RIGHT, BOTTOM, LEFT),
!             'Widget': 'readonly',
!             }
  
  class RemotePackDialog(PackDialog):
  
!     def __init__(self, master, app, widget):
!         self.master = master
!         self.app = app
!         self.widget = widget
!         self.refresh()
!         self.top = Toplevel(self.master)
!         self.top.title(self.app + ' PackDialog')
!         self.top.minsize(1, 1)
!         self.addchoices()
  
!     def refresh(self):
!         try:
!             words = self.master.tk.splitlist(
!                     self.master.send(self.app,
!                                      'pack',
!                                      'info',
!                                      self.widget))
!         except TclError, msg:
!             print msg
!             return
!         dict = {}
!         for i in range(0, len(words), 2):
!             key = words[i][1:]
!             value = words[i+1]
!             dict[key] = value
!         dict['.class'] = self.master.send(self.app,
!                                           'winfo',
!                                           'class',
!                                           self.widget)
!         dict['.name'] = self.widget
!         self.current = dict
  
!     class remotepackoption: # Mix-in class
!         def set(self, e=None):
!             self.current = self.var.get()
!             try:
!                 self.dialog.master.send(
!                         self.dialog.app,
!                         'pack',
!                         'config',
!                         self.dialog.widget,
!                         '-'+self.option,
!                         self.dialog.master.tk.merge(
!                                 self.current))
!             except TclError, msg:
!                 print msg
!                 self.refresh()
  
!     class booleanoption(remotepackoption, BooleanOption): pass
!     class enumoption(remotepackoption, EnumOption): pass
!     class stringoption(remotepackoption, StringOption): pass
!     class readonlyoption(remotepackoption, ReadonlyOption): pass
  
  class WidgetDialog(Dialog):
  
!     def __init__(self, widget):
!         self.widget = widget
!         self.klass = widget.winfo_class()
!         Dialog.__init__(self, widget)
  
!     def fixclasses(self):
!         if self.addclasses.has_key(self.klass):
!             classes = {}
!             for c in (self.classes,
!                       self.addclasses[self.klass]):
!                 for k in c.keys():
!                     classes[k] = c[k]
!             self.classes = classes
  
!     def refresh(self):
!         self.configuration = self.widget.config()
!         self.update()
!         self.current['.class'] = self.widget.winfo_class()
!         self.current['.name'] = self.widget._w
  
!     def update(self):
!         self.current = {}
!         self.options = {}
!         for k, v in self.configuration.items():
!             if len(v) > 4:
!                 self.current[k] = v[4]
!                 self.options[k] = v[3], v[2] # default, klass
!         self.options['.class'] = (None, 'Class')
!         self.options['.name'] = (None, 'Name')
  
!     class widgetoption: # Mix-in class
!         def set(self, e=None):
!             self.current = self.var.get()
!             try:
!                 self.dialog.widget[self.option] = self.current
!             except TclError, msg:
!                 print msg
!                 self.refresh()
  
!     class booleanoption(widgetoption, BooleanOption): pass
!     class enumoption(widgetoption, EnumOption): pass
!     class stringoption(widgetoption, StringOption): pass
!     class readonlyoption(widgetoption, ReadonlyOption): pass
  
!     # Universal classes
!     classes = {
!             'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER),
!             'Aspect': 'integer',
!             'Background': 'color',
!             'Bitmap': 'bitmap',
!             'BorderWidth': 'pixel',
!             'Class': 'readonly',
!             'CloseEnough': 'double',
!             'Command': 'command',
!             'Confine': 'boolean',
!             'Cursor': 'cursor',
!             'CursorWidth': 'pixel',
!             'DisabledForeground': 'color',
!             'ExportSelection': 'boolean',
!             'Font': 'font',
!             'Foreground': 'color',
!             'From': 'integer',
!             'Geometry': 'geometry',
!             'Height': 'pixel',
!             'InsertWidth': 'time',
!             'Justify': (LEFT, CENTER, RIGHT),
!             'Label': 'string',
!             'Length': 'pixel',
!             'MenuName': 'widget',
!             'Name': 'readonly',
!             'OffTime': 'time',
!             'OnTime': 'time',
!             'Orient': (HORIZONTAL, VERTICAL),
!             'Pad': 'pixel',
!             'Relief': (RAISED, SUNKEN, FLAT, RIDGE, GROOVE),
!             'RepeatDelay': 'time',
!             'RepeatInterval': 'time',
!             'ScrollCommand': 'command',
!             'ScrollIncrement': 'pixel',
!             'ScrollRegion': 'rectangle',
!             'ShowValue': 'boolean',
!             'SetGrid': 'boolean',
!             'Sliderforeground': 'color',
!             'SliderLength': 'pixel',
!             'Text': 'string',
!             'TickInterval': 'integer',
!             'To': 'integer',
!             'Underline': 'index',
!             'Variable': 'variable',
!             'Value': 'string',
!             'Width': 'pixel',
!             'Wrap': (NONE, CHAR, WORD),
!             }
  
!     # Classes that (may) differ per widget type
!     _tristate = {'State': (NORMAL, ACTIVE, DISABLED)}
!     _bistate = {'State': (NORMAL, DISABLED)}
!     addclasses = {
!             'Button': _tristate,
!             'Radiobutton': _tristate,
!             'Checkbutton': _tristate,
!             'Entry': _bistate,
!             'Text': _bistate,
!             'Menubutton': _tristate,
!             'Slider': _bistate,
!             }
  
  class RemoteWidgetDialog(WidgetDialog):
  
!     def __init__(self, master, app, widget):
!         self.app = app
!         self.widget = widget
!         self.klass = master.send(self.app,
!                                  'winfo',
!                                  'class',
!                                  self.widget)
!         Dialog.__init__(self, master)
  
!     def refresh(self):
!         try:
!             items = self.master.tk.splitlist(
!                     self.master.send(self.app,
!                                      self.widget,
!                                      'config'))
!         except TclError, msg:
!             print msg
!             return
!         dict = {}
!         for item in items:
!             words = self.master.tk.splitlist(item)
!             key = words[0][1:]
!             value = (key,) + words[1:]
!             dict[key] = value
!         self.configuration = dict
!         self.update()
!         self.current['.class'] = self.klass
!         self.current['.name'] = self.widget
  
!     class remotewidgetoption: # Mix-in class
!         def set(self, e=None):
!             self.current = self.var.get()
!             try:
!                 self.dialog.master.send(
!                         self.dialog.app,
!                         self.dialog.widget,
!                         'config',
!                         '-'+self.option,
!                         self.current)
!             except TclError, msg:
!                 print msg
!                 self.refresh()
  
!     class booleanoption(remotewidgetoption, BooleanOption): pass
!     class enumoption(remotewidgetoption, EnumOption): pass
!     class stringoption(remotewidgetoption, StringOption): pass
!     class readonlyoption(remotewidgetoption, ReadonlyOption): pass
  
  def test():
!     import sys
!     root = Tk()
!     root.minsize(1, 1)
!     if sys.argv[1:]:
!         remotetest(root, sys.argv[1])
!     else:
!         frame = Frame(root, name='frame')
!         frame.pack(expand=1, fill=BOTH)
!         button = Button(frame, name='button', text='button')
!         button.pack(expand=1)
!         canvas = Canvas(frame, name='canvas')
!         canvas.pack()
!         fpd = PackDialog(frame)
!         fwd = WidgetDialog(frame)
!         bpd = PackDialog(button)
!         bwd = WidgetDialog(button)
!         cpd = PackDialog(canvas)
!         cwd = WidgetDialog(canvas)
!     root.mainloop()
  
  def remotetest(root, app):
!     from listtree import listtree
!     list = listtree(root, app)
!     list.bind('<Any-Double-1>', opendialogs)
!     list.app = app                  # Pass it on to handler
  
  def opendialogs(e):
!     import string
!     list = e.widget
!     sel = list.curselection()
!     for i in sel:
!         item = list.get(i)
!         widget = string.split(item)[0]
!         RemoteWidgetDialog(list, list.app, widget)
!         if widget == '.': continue
!         try:
!             RemotePackDialog(list, list.app, widget)
!         except TclError, msg:
!             print msg
  
  test()

Index: ManPage.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/ManPage.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ManPage.py	30 Jul 1996 18:56:03 -0000	1.9
--- ManPage.py	18 Jul 2004 06:09:08 -0000	1.10
***************
*** 13,17 ****
  # (This one works for IRIX 5.2 and Solaris 2.2)
  footerprog = regex.compile(
! 	'^     Page [1-9][0-9]*[ \t]+\|^.*Last change:.*[1-9][0-9]*\n')
  emptyprog = regex.compile('^[ \t]*\n')
  ulprog = regex.compile('^[ \t]*[Xv!_][Xv!_ \t]*\n')
--- 13,17 ----
  # (This one works for IRIX 5.2 and Solaris 2.2)
  footerprog = regex.compile(
!         '^     Page [1-9][0-9]*[ \t]+\|^.*Last change:.*[1-9][0-9]*\n')
  emptyprog = regex.compile('^[ \t]*\n')
  ulprog = regex.compile('^[ \t]*[Xv!_][Xv!_ \t]*\n')
***************
*** 20,183 ****
  class EditableManPage(ScrolledText):
  
! 	# Initialize instance
! 	def __init__(self, master=None, **cnf):
! 		# Initialize base class
! 		apply(ScrolledText.__init__, (self, master), cnf)
  
! 		# Define tags for formatting styles
! 		self.tag_config('X', underline=1)
! 		self.tag_config('!', font=BOLDFONT)
! 		self.tag_config('_', font=ITALICFONT)
  
! 		# Set state to idle
! 		self.fp = None
! 		self.lineno = 0
  
! 	# Test whether we are busy parsing a file
! 	def busy(self):
! 		return self.fp != None
  
! 	# Ensure we're not busy
! 	def kill(self):
! 		if self.busy():
! 			self._endparser()
  
! 	# Parse a file, in the background
! 	def asyncparsefile(self, fp):
! 		self._startparser(fp)
! 		self.tk.createfilehandler(fp, _tkinter.READABLE,
! 					  self._filehandler)
  
! 	parsefile = asyncparsefile	# Alias
  
! 	# I/O handler used by background parsing
! 	def _filehandler(self, fp, mask):
! 		nextline = self.fp.readline()
! 		if not nextline:
! 			self._endparser()
! 			return
! 		self._parseline(nextline)
  
! 	# Parse a file, now (cannot be aborted)
! 	def syncparsefile(self, fp):
! 		from select import select
! 		def avail(fp=fp, tout=0.0, select=select):
! 			return select([fp], [], [], tout)[0]
! 		height = self.getint(self['height'])
! 		self._startparser(fp)
! 		while 1:
! 			nextline = fp.readline()
! 			if not nextline:
! 				break
! 			self._parseline(nextline)
! 		self._endparser()
  
! 	# Initialize parsing from a particular file -- must not be busy
! 	def _startparser(self, fp):
! 		if self.busy():
! 			raise RuntimeError, 'startparser: still busy'
! 		fp.fileno()		# Test for file-ness
! 		self.fp = fp
! 		self.lineno = 0
! 		self.ok = 0
! 		self.empty = 0
! 		self.buffer = None
! 		savestate = self['state']
! 		self['state'] = NORMAL
! 		self.delete('1.0', END)
! 		self['state'] = savestate
  
! 	# End parsing -- must be busy, need not be at EOF
! 	def _endparser(self):
! 		if not self.busy():
! 			raise RuntimeError, 'endparser: not busy'
! 		if self.buffer:
! 			self._parseline('')
! 		try:
! 			self.tk.deletefilehandler(self.fp)
! 		except TclError, msg:
! 			pass
! 		self.fp.close()
! 		self.fp = None
! 		del self.ok, self.empty, self.buffer
  
! 	# Parse a single line
! 	def _parseline(self, nextline):
! 		if not self.buffer:
! 			# Save this line -- we need one line read-ahead
! 			self.buffer = nextline
! 			return
! 		if emptyprog.match(self.buffer) >= 0:
! 			# Buffered line was empty -- set a flag
! 			self.empty = 1
! 			self.buffer = nextline
! 			return
! 		textline = self.buffer
! 		if ulprog.match(nextline) >= 0:
! 			# Next line is properties for buffered line
! 			propline = nextline
! 			self.buffer = None
! 		else:
! 			# Next line is read-ahead
! 			propline = None
! 			self.buffer = nextline
! 		if not self.ok:
! 			# First non blank line after footer must be header
! 			# -- skip that too
! 			self.ok = 1
! 			self.empty = 0
! 			return
! 		if footerprog.match(textline) >= 0:
! 			# Footer -- start skipping until next non-blank line
! 			self.ok = 0
! 			self.empty = 0
! 			return
! 		savestate = self['state']
! 		self['state'] = NORMAL
! 		if TkVersion >= 4.0:
! 			self.mark_set('insert', 'end-1c')
! 		else:
! 			self.mark_set('insert', END)
! 		if self.empty:
! 			# One or more previous lines were empty
! 			# -- insert one blank line in the text
! 			self._insert_prop('\n')
! 			self.lineno = self.lineno + 1
! 			self.empty = 0
! 		if not propline:
! 			# No properties
! 			self._insert_prop(textline)
! 		else:
! 			# Search for properties
! 			p = ''
! 			j = 0
! 			for i in range(min(len(propline), len(textline))):
! 				if propline[i] != p:
! 					if j < i:
! 					    self._insert_prop(textline[j:i], p)
! 					    j = i
! 					p = propline[i]
! 			self._insert_prop(textline[j:])
! 		self.lineno = self.lineno + 1
! 		self['state'] = savestate
  
! 	# Insert a string at the end, with at most one property (tag)
! 	def _insert_prop(self, str, prop = ' '):
! 		here = self.index(AtInsert())
! 		self.insert(AtInsert(), str)
! 		if TkVersion <= 4.0:
! 			tags = self.tag_names(here)
! 			for tag in tags:
! 				self.tag_remove(tag, here, AtInsert())
! 		if prop != ' ':
! 			self.tag_add(prop, here, AtInsert())
  
  # Readonly Man Page class -- disables editing, otherwise the same
  class ReadonlyManPage(EditableManPage):
  
! 	# Initialize instance
! 	def __init__(self, master=None, **cnf):
! 		cnf['state'] = DISABLED
! 		apply(EditableManPage.__init__, (self, master), cnf)
  
  # Alias
--- 20,183 ----
  class EditableManPage(ScrolledText):
  
!     # Initialize instance
!     def __init__(self, master=None, **cnf):
!         # Initialize base class
!         apply(ScrolledText.__init__, (self, master), cnf)
  
!         # Define tags for formatting styles
!         self.tag_config('X', underline=1)
!         self.tag_config('!', font=BOLDFONT)
!         self.tag_config('_', font=ITALICFONT)
  
!         # Set state to idle
!         self.fp = None
!         self.lineno = 0
  
!     # Test whether we are busy parsing a file
!     def busy(self):
!         return self.fp != None
  
!     # Ensure we're not busy
!     def kill(self):
!         if self.busy():
!             self._endparser()
  
!     # Parse a file, in the background
!     def asyncparsefile(self, fp):
!         self._startparser(fp)
!         self.tk.createfilehandler(fp, _tkinter.READABLE,
!                                   self._filehandler)
  
!     parsefile = asyncparsefile      # Alias
  
!     # I/O handler used by background parsing
!     def _filehandler(self, fp, mask):
!         nextline = self.fp.readline()
!         if not nextline:
!             self._endparser()
!             return
!         self._parseline(nextline)
  
!     # Parse a file, now (cannot be aborted)
!     def syncparsefile(self, fp):
!         from select import select
!         def avail(fp=fp, tout=0.0, select=select):
!             return select([fp], [], [], tout)[0]
!         height = self.getint(self['height'])
!         self._startparser(fp)
!         while 1:
!             nextline = fp.readline()
!             if not nextline:
!                 break
!             self._parseline(nextline)
!         self._endparser()
  
!     # Initialize parsing from a particular file -- must not be busy
!     def _startparser(self, fp):
!         if self.busy():
!             raise RuntimeError, 'startparser: still busy'
!         fp.fileno()             # Test for file-ness
!         self.fp = fp
!         self.lineno = 0
!         self.ok = 0
!         self.empty = 0
!         self.buffer = None
!         savestate = self['state']
!         self['state'] = NORMAL
!         self.delete('1.0', END)
!         self['state'] = savestate
  
!     # End parsing -- must be busy, need not be at EOF
!     def _endparser(self):
!         if not self.busy():
!             raise RuntimeError, 'endparser: not busy'
!         if self.buffer:
!             self._parseline('')
!         try:
!             self.tk.deletefilehandler(self.fp)
!         except TclError, msg:
!             pass
!         self.fp.close()
!         self.fp = None
!         del self.ok, self.empty, self.buffer
  
!     # Parse a single line
!     def _parseline(self, nextline):
!         if not self.buffer:
!             # Save this line -- we need one line read-ahead
!             self.buffer = nextline
!             return
!         if emptyprog.match(self.buffer) >= 0:
!             # Buffered line was empty -- set a flag
!             self.empty = 1
!             self.buffer = nextline
!             return
!         textline = self.buffer
!         if ulprog.match(nextline) >= 0:
!             # Next line is properties for buffered line
!             propline = nextline
!             self.buffer = None
!         else:
!             # Next line is read-ahead
!             propline = None
!             self.buffer = nextline
!         if not self.ok:
!             # First non blank line after footer must be header
!             # -- skip that too
!             self.ok = 1
!             self.empty = 0
!             return
!         if footerprog.match(textline) >= 0:
!             # Footer -- start skipping until next non-blank line
!             self.ok = 0
!             self.empty = 0
!             return
!         savestate = self['state']
!         self['state'] = NORMAL
!         if TkVersion >= 4.0:
!             self.mark_set('insert', 'end-1c')
!         else:
!             self.mark_set('insert', END)
!         if self.empty:
!             # One or more previous lines were empty
!             # -- insert one blank line in the text
!             self._insert_prop('\n')
!             self.lineno = self.lineno + 1
!             self.empty = 0
!         if not propline:
!             # No properties
!             self._insert_prop(textline)
!         else:
!             # Search for properties
!             p = ''
!             j = 0
!             for i in range(min(len(propline), len(textline))):
!                 if propline[i] != p:
!                     if j < i:
!                         self._insert_prop(textline[j:i], p)
!                         j = i
!                     p = propline[i]
!             self._insert_prop(textline[j:])
!         self.lineno = self.lineno + 1
!         self['state'] = savestate
  
!     # Insert a string at the end, with at most one property (tag)
!     def _insert_prop(self, str, prop = ' '):
!         here = self.index(AtInsert())
!         self.insert(AtInsert(), str)
!         if TkVersion <= 4.0:
!             tags = self.tag_names(here)
!             for tag in tags:
!                 self.tag_remove(tag, here, AtInsert())
!         if prop != ' ':
!             self.tag_add(prop, here, AtInsert())
  
  # Readonly Man Page class -- disables editing, otherwise the same
  class ReadonlyManPage(EditableManPage):
  
!     # Initialize instance
!     def __init__(self, master=None, **cnf):
!         cnf['state'] = DISABLED
!         apply(EditableManPage.__init__, (self, master), cnf)
  
  # Alias
***************
*** 188,220 ****
  # -f means that the file is nroff -man output run through ul -i
  def test():
! 	import os
! 	import sys
! 	# XXX This directory may be different on your system
! 	MANDIR = '/usr/local/man/mann'
! 	DEFAULTPAGE = 'Tcl'
! 	formatted = 0
! 	if sys.argv[1:] and sys.argv[1] == '-f':
! 		formatted = 1
! 		del sys.argv[1]
! 	if sys.argv[1:]:
! 		name = sys.argv[1]
! 	else:
! 		name = DEFAULTPAGE
! 	if not formatted:
! 		if name[-2:-1] != '.':
! 			name = name + '.n'
! 		name = os.path.join(MANDIR, name)
! 	root = Tk()
! 	root.minsize(1, 1)
! 	manpage = ManPage(root, relief=SUNKEN, borderwidth=2)
! 	manpage.pack(expand=1, fill=BOTH)
! 	if formatted:
! 		fp = open(name, 'r')
! 	else:
! 		fp = os.popen('nroff -man %s | ul -i' % name, 'r')
! 	manpage.parsefile(fp)
! 	root.mainloop()
  
  # Run the test program when called as a script
  if __name__ == '__main__':
! 	test()
--- 188,220 ----
  # -f means that the file is nroff -man output run through ul -i
  def test():
!     import os
!     import sys
!     # XXX This directory may be different on your system
!     MANDIR = '/usr/local/man/mann'
!     DEFAULTPAGE = 'Tcl'
!     formatted = 0
!     if sys.argv[1:] and sys.argv[1] == '-f':
!         formatted = 1
!         del sys.argv[1]
!     if sys.argv[1:]:
!         name = sys.argv[1]
!     else:
!         name = DEFAULTPAGE
!     if not formatted:
!         if name[-2:-1] != '.':
!             name = name + '.n'
!         name = os.path.join(MANDIR, name)
!     root = Tk()
!     root.minsize(1, 1)
!     manpage = ManPage(root, relief=SUNKEN, borderwidth=2)
!     manpage.pack(expand=1, fill=BOTH)
!     if formatted:
!         fp = open(name, 'r')
!     else:
!         fp = os.popen('nroff -man %s | ul -i' % name, 'r')
!     manpage.parsefile(fp)
!     root.mainloop()
  
  # Run the test program when called as a script
  if __name__ == '__main__':
!     test()

Index: MimeViewer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/MimeViewer.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** MimeViewer.py	27 Nov 1996 19:51:20 -0000	1.3
--- MimeViewer.py	18 Jul 2004 06:09:08 -0000	1.4
***************
*** 10,143 ****
  
  class MimeViewer:
! 	def __init__(self, parent, title, msg):
! 		self.title = title
! 		self.msg = msg
! 		self.frame = Frame(parent, {'relief': 'raised', 'bd': 2})
! 		self.frame.packing = {'expand': 0, 'fill': 'both'}
! 		self.button = Checkbutton(self.frame,
! 				     {'text': title,
! 				      'command': self.toggle})
! 		self.button.pack({'anchor': 'w'})
! 		headertext = msg.getheadertext(
! 			lambda x: x != 'received' and x[:5] != 'x400-')
! 		height = countlines(headertext, 4)
! 		if height:
! 			self.htext = ScrolledText(self.frame,
! 					  {'height': height,
! 					   'width': 80,
! 					   'wrap': 'none',
! 					   'relief': 'raised',
! 					   'bd': 2})
! 			self.htext.packing = {'expand': 1, 'fill': 'both',
! 					      'after': self.button}
! 			self.htext.insert('end', headertext)
! 		else:
! 			self.htext = Frame(self.frame,
! 					   {'relief': 'raised', 'bd': 2})
! 			self.htext.packing = {'side': 'top',
! 					      'ipady': 2,
! 					      'fill': 'x',
! 					      'after': self.button}
! 		body = msg.getbody()
! 		if type(body) == StringType:
! 			self.pad = None
! 			height = countlines(body, 10)
! 			if height:
! 				self.btext = ScrolledText(self.frame,
! 						  {'height': height,
! 						   'width': 80,
! 						   'wrap': 'none',
! 						   'relief': 'raised',
! 						   'bd': 2})
! 				self.btext.packing = {'expand': 1,
! 						      'fill': 'both'}
! 				self.btext.insert('end', body)
! 			else:
! 				self.btext = None
! 			self.parts = None
! 		else:
! 			self.pad = Frame(self.frame,
! 					 {'relief': 'flat', 'bd': 2})
! 			self.pad.packing = {'side': 'left', 'ipadx': 10,
! 					    'fill': 'y', 'after': self.htext}
! 			self.parts = []
! 			for i in range(len(body)):
! 				p = MimeViewer(self.frame,
! 					       '%s.%d' % (title, i+1),
! 					       body[i])
! 				self.parts.append(p)
! 			self.btext = None
! 		self.collapsed = 1
! 	def pack(self):
! 		self.frame.pack(self.frame.packing)
! 	def destroy(self):
! 		self.frame.destroy()
! 	def show(self):
! 		if self.collapsed:
! 			self.button.invoke()
! 	def toggle(self):
! 		if self.collapsed:
! 			self.explode()
! 		else:
! 			self.collapse()
! 	def collapse(self):
! 		self.collapsed = 1
! 		for comp in self.htext, self.btext, self.pad:
! 			if comp:
! 				comp.forget()
! 		if self.parts:
! 			for part in self.parts:
! 				part.frame.forget()
! 		self.frame.pack({'expand': 0})
! 	def explode(self):
! 		self.collapsed = 0
! 		for comp in self.htext, self.btext, self.pad:
! 			if comp: comp.pack(comp.packing)
! 		if self.parts:
! 			for part in self.parts:
! 				part.pack()
! 		self.frame.pack({'expand': 1})
  
  def countlines(str, limit):
! 	i = 0
! 	n = 0
! 	while  n < limit:
! 		i = string.find(str, '\n', i)
! 		if i < 0: break
! 		n = n+1
! 		i = i+1
! 	return n
  
  def main():
! 	import sys
! 	import getopt
! 	import mhlib
! 	opts, args = getopt.getopt(sys.argv[1:], '')
! 	for o, a in opts:
! 		pass
! 	message = None
! 	folder = 'inbox'
! 	for arg in args:
! 		if arg[:1] == '+':
! 			folder = arg[1:]
! 		else:
! 			message = string.atoi(arg)
  
! 	mh = mhlib.MH()
! 	f = mh.openfolder(folder)
! 	if not message:
! 		message = f.getcurrent()
! 	m = f.openmessage(message)
  
! 	root = Tk()
! 	tk = root.tk
  
! 	top = MimeViewer(root, '+%s/%d' % (folder, message), m)
! 	top.pack()
! 	top.show()
  
! 	root.minsize(1, 1)
  
! 	tk.mainloop()
  
  if __name__ == '__main__': main()
--- 10,143 ----
  
  class MimeViewer:
!     def __init__(self, parent, title, msg):
!         self.title = title
!         self.msg = msg
!         self.frame = Frame(parent, {'relief': 'raised', 'bd': 2})
!         self.frame.packing = {'expand': 0, 'fill': 'both'}
!         self.button = Checkbutton(self.frame,
!                              {'text': title,
!                               'command': self.toggle})
!         self.button.pack({'anchor': 'w'})
!         headertext = msg.getheadertext(
!                 lambda x: x != 'received' and x[:5] != 'x400-')
!         height = countlines(headertext, 4)
!         if height:
!             self.htext = ScrolledText(self.frame,
!                               {'height': height,
!                                'width': 80,
!                                'wrap': 'none',
!                                'relief': 'raised',
!                                'bd': 2})
!             self.htext.packing = {'expand': 1, 'fill': 'both',
!                                   'after': self.button}
!             self.htext.insert('end', headertext)
!         else:
!             self.htext = Frame(self.frame,
!                                {'relief': 'raised', 'bd': 2})
!             self.htext.packing = {'side': 'top',
!                                   'ipady': 2,
!                                   'fill': 'x',
!                                   'after': self.button}
!         body = msg.getbody()
!         if type(body) == StringType:
!             self.pad = None
!             height = countlines(body, 10)
!             if height:
!                 self.btext = ScrolledText(self.frame,
!                                   {'height': height,
!                                    'width': 80,
!                                    'wrap': 'none',
!                                    'relief': 'raised',
!                                    'bd': 2})
!                 self.btext.packing = {'expand': 1,
!                                       'fill': 'both'}
!                 self.btext.insert('end', body)
!             else:
!                 self.btext = None
!             self.parts = None
!         else:
!             self.pad = Frame(self.frame,
!                              {'relief': 'flat', 'bd': 2})
!             self.pad.packing = {'side': 'left', 'ipadx': 10,
!                                 'fill': 'y', 'after': self.htext}
!             self.parts = []
!             for i in range(len(body)):
!                 p = MimeViewer(self.frame,
!                                '%s.%d' % (title, i+1),
!                                body[i])
!                 self.parts.append(p)
!             self.btext = None
!         self.collapsed = 1
!     def pack(self):
!         self.frame.pack(self.frame.packing)
!     def destroy(self):
!         self.frame.destroy()
!     def show(self):
!         if self.collapsed:
!             self.button.invoke()
!     def toggle(self):
!         if self.collapsed:
!             self.explode()
!         else:
!             self.collapse()
!     def collapse(self):
!         self.collapsed = 1
!         for comp in self.htext, self.btext, self.pad:
!             if comp:
!                 comp.forget()
!         if self.parts:
!             for part in self.parts:
!                 part.frame.forget()
!         self.frame.pack({'expand': 0})
!     def explode(self):
!         self.collapsed = 0
!         for comp in self.htext, self.btext, self.pad:
!             if comp: comp.pack(comp.packing)
!         if self.parts:
!             for part in self.parts:
!                 part.pack()
!         self.frame.pack({'expand': 1})
  
  def countlines(str, limit):
!     i = 0
!     n = 0
!     while  n < limit:
!         i = string.find(str, '\n', i)
!         if i < 0: break
!         n = n+1
!         i = i+1
!     return n
  
  def main():
!     import sys
!     import getopt
!     import mhlib
!     opts, args = getopt.getopt(sys.argv[1:], '')
!     for o, a in opts:
!         pass
!     message = None
!     folder = 'inbox'
!     for arg in args:
!         if arg[:1] == '+':
!             folder = arg[1:]
!         else:
!             message = string.atoi(arg)
  
!     mh = mhlib.MH()
!     f = mh.openfolder(folder)
!     if not message:
!         message = f.getcurrent()
!     m = f.openmessage(message)
  
!     root = Tk()
!     tk = root.tk
  
!     top = MimeViewer(root, '+%s/%d' % (folder, message), m)
!     top.pack()
!     top.show()
  
!     root.minsize(1, 1)
  
!     tk.mainloop()
  
  if __name__ == '__main__': main()

Index: ShellWindow.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/ShellWindow.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ShellWindow.py	7 Oct 1997 14:37:31 -0000	1.3
--- ShellWindow.py	18 Jul 2004 06:09:08 -0000	1.4
***************
*** 11,151 ****
  class ShellWindow(ScrolledText):
  
! 	def __init__(self, master=None, shell=None, **cnf):
! 		if not shell:
! 			try:
! 				shell = os.environ['SHELL']
! 			except KeyError:
! 				shell = '/bin/sh'
! 			shell = shell + ' -i'
! 		args = string.split(shell)
! 		shell = args[0]
  
! 		apply(ScrolledText.__init__, (self, master), cnf)
! 		self.pos = '1.0'
! 		self.bind('<Return>', self.inputhandler)
! 		self.bind('<Control-c>', self.sigint)
! 		self.bind('<Control-t>', self.sigterm)
! 		self.bind('<Control-k>', self.sigkill)
! 		self.bind('<Control-d>', self.sendeof)
  
! 		self.pid, self.fromchild, self.tochild = spawn(shell, args)
! 		self.tk.createfilehandler(self.fromchild, READABLE,
! 					  self.outputhandler)
  
! 	def outputhandler(self, file, mask):
! 		data = os.read(file, BUFSIZE)
! 		if not data:
! 			self.tk.deletefilehandler(file)
! 			pid, sts = os.waitpid(self.pid, 0)
! 			print 'pid', pid, 'status', sts
! 			self.pid = None
! 			detail = sts>>8
! 			cause = sts & 0xff
! 			if cause == 0:
! 				msg = "exit status %d" % detail
! 			else:
! 				msg = "killed by signal %d" % (cause & 0x7f)
! 				if cause & 0x80:
! 					msg = msg + " -- core dumped"
! 			Dialog(self.master,
! 			       text=msg,
! 			       title="Exit status",
! 			       bitmap='warning',
! 			       default=0,
! 			       strings=('OK',))
! 			return
! 		self.insert(END, data)
! 		self.pos = self.index("end - 1 char")
! 		self.yview_pickplace(END)
  
! 	def inputhandler(self, *args):
! 		if not self.pid:
! 			self.no_process()
! 			return "break"
! 		self.insert(END, "\n")
! 		line = self.get(self.pos, "end - 1 char")
! 		self.pos = self.index(END)
! 		os.write(self.tochild, line)
! 		return "break"
  
! 	def sendeof(self, *args):
! 		if not self.pid:
! 			self.no_process()
! 			return "break"
! 		os.close(self.tochild)
! 		return "break"
  
! 	def sendsig(self, sig):
! 		if not self.pid:
! 			self.no_process()
! 			return "break"
! 		os.kill(self.pid, sig)
! 		return "break"
  
! 	def sigint(self, *args):
! 		return self.sendsig(signal.SIGINT)
  
! 	def sigquit(self, *args):
! 		return self.sendsig(signal.SIGQUIT)
  
! 	def sigterm(self, *args):
! 		return self.sendsig(signal.SIGTERM)
  
! 	def sigkill(self, *args):
! 		return self.sendsig(signal.SIGKILL)
  
! 	def no_process(self):
! 		Dialog(self.master,
! 		       text="No active process",
! 		       title="No process",
! 		       bitmap='error',
! 		       default=0,
! 		       strings=('OK',))
  
! MAXFD = 100	# Max number of file descriptors (os.getdtablesize()???)
  
  def spawn(prog, args):
! 	p2cread, p2cwrite = os.pipe()
! 	c2pread, c2pwrite = os.pipe()
! 	pid = os.fork()
! 	if pid == 0:
! 		# Child
! 		for i in 0, 1, 2:
! 		    try:
! 			os.close(i)
! 		    except os.error:
! 			pass
! 		if os.dup(p2cread) <> 0:
! 			sys.stderr.write('popen2: bad read dup\n')
! 		if os.dup(c2pwrite) <> 1:
! 			sys.stderr.write('popen2: bad write dup\n')
! 		if os.dup(c2pwrite) <> 2:
! 			sys.stderr.write('popen2: bad write dup\n')
! 		for i in range(3, MAXFD):
! 			try:
! 				os.close(i)
! 			except:
! 				pass
! 		try:
! 			os.execvp(prog, args)
! 		finally:
! 			sys.stderr.write('execvp failed\n')
! 			os._exit(1)
! 	os.close(p2cread)
! 	os.close(c2pwrite)
! 	return pid, c2pread, p2cwrite
  
  def test():
! 	shell = string.join(sys.argv[1:])
! 	root = Tk()
! 	root.minsize(1, 1)
! 	if shell:
! 	    w = ShellWindow(root, shell=shell)
! 	else:
! 	    w = ShellWindow(root)
! 	w.pack(expand=1, fill=BOTH)
! 	w.focus_set()
! 	w.tk.mainloop()
  
  if __name__ == '__main__':
! 	test()
--- 11,151 ----
  class ShellWindow(ScrolledText):
  
!     def __init__(self, master=None, shell=None, **cnf):
!         if not shell:
!             try:
!                 shell = os.environ['SHELL']
!             except KeyError:
!                 shell = '/bin/sh'
!             shell = shell + ' -i'
!         args = string.split(shell)
!         shell = args[0]
  
!         apply(ScrolledText.__init__, (self, master), cnf)
!         self.pos = '1.0'
!         self.bind('<Return>', self.inputhandler)
!         self.bind('<Control-c>', self.sigint)
!         self.bind('<Control-t>', self.sigterm)
!         self.bind('<Control-k>', self.sigkill)
!         self.bind('<Control-d>', self.sendeof)
  
!         self.pid, self.fromchild, self.tochild = spawn(shell, args)
!         self.tk.createfilehandler(self.fromchild, READABLE,
!                                   self.outputhandler)
  
!     def outputhandler(self, file, mask):
!         data = os.read(file, BUFSIZE)
!         if not data:
!             self.tk.deletefilehandler(file)
!             pid, sts = os.waitpid(self.pid, 0)
!             print 'pid', pid, 'status', sts
!             self.pid = None
!             detail = sts>>8
!             cause = sts & 0xff
!             if cause == 0:
!                 msg = "exit status %d" % detail
!             else:
!                 msg = "killed by signal %d" % (cause & 0x7f)
!                 if cause & 0x80:
!                     msg = msg + " -- core dumped"
!             Dialog(self.master,
!                    text=msg,
!                    title="Exit status",
!                    bitmap='warning',
!                    default=0,
!                    strings=('OK',))
!             return
!         self.insert(END, data)
!         self.pos = self.index("end - 1 char")
!         self.yview_pickplace(END)
  
!     def inputhandler(self, *args):
!         if not self.pid:
!             self.no_process()
!             return "break"
!         self.insert(END, "\n")
!         line = self.get(self.pos, "end - 1 char")
!         self.pos = self.index(END)
!         os.write(self.tochild, line)
!         return "break"
  
!     def sendeof(self, *args):
!         if not self.pid:
!             self.no_process()
!             return "break"
!         os.close(self.tochild)
!         return "break"
  
!     def sendsig(self, sig):
!         if not self.pid:
!             self.no_process()
!             return "break"
!         os.kill(self.pid, sig)
!         return "break"
  
!     def sigint(self, *args):
!         return self.sendsig(signal.SIGINT)
  
!     def sigquit(self, *args):
!         return self.sendsig(signal.SIGQUIT)
  
!     def sigterm(self, *args):
!         return self.sendsig(signal.SIGTERM)
  
!     def sigkill(self, *args):
!         return self.sendsig(signal.SIGKILL)
  
!     def no_process(self):
!         Dialog(self.master,
!                text="No active process",
!                title="No process",
!                bitmap='error',
!                default=0,
!                strings=('OK',))
  
! MAXFD = 100     # Max number of file descriptors (os.getdtablesize()???)
  
  def spawn(prog, args):
!     p2cread, p2cwrite = os.pipe()
!     c2pread, c2pwrite = os.pipe()
!     pid = os.fork()
!     if pid == 0:
!         # Child
!         for i in 0, 1, 2:
!             try:
!                 os.close(i)
!             except os.error:
!                 pass
!         if os.dup(p2cread) <> 0:
!             sys.stderr.write('popen2: bad read dup\n')
!         if os.dup(c2pwrite) <> 1:
!             sys.stderr.write('popen2: bad write dup\n')
!         if os.dup(c2pwrite) <> 2:
!             sys.stderr.write('popen2: bad write dup\n')
!         for i in range(3, MAXFD):
!             try:
!                 os.close(i)
!             except:
!                 pass
!         try:
!             os.execvp(prog, args)
!         finally:
!             sys.stderr.write('execvp failed\n')
!             os._exit(1)
!     os.close(p2cread)
!     os.close(c2pwrite)
!     return pid, c2pread, p2cwrite
  
  def test():
!     shell = string.join(sys.argv[1:])
!     root = Tk()
!     root.minsize(1, 1)
!     if shell:
!         w = ShellWindow(root, shell=shell)
!     else:
!         w = ShellWindow(root)
!     w.pack(expand=1, fill=BOTH)
!     w.focus_set()
!     w.tk.mainloop()
  
  if __name__ == '__main__':
!     test()

Index: canvasevents.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/canvasevents.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** canvasevents.py	3 Apr 1997 00:04:43 -0000	1.1
--- canvasevents.py	18 Jul 2004 06:09:08 -0000	1.2
***************
*** 10,14 ****
  class Group(Group):
      def bind(self, sequence=None, command=None):
! 	return self.canvas.tag_bind(self.id, sequence, command)
  
  class Object:
--- 10,14 ----
  class Group(Group):
      def bind(self, sequence=None, command=None):
!         return self.canvas.tag_bind(self.id, sequence, command)
  
  class Object:
***************
*** 34,76 ****
  
      def __init__(self, canvas, x=0, y=0, fill='red', text='object'):
! 	self.canvas = canvas
! 	self.x = x
! 	self.y = y
! 	self.pile = None
! 	self.group = Group(self.canvas)
! 	self.createitems(fill, text)
  
      def __str__(self):
! 	return str(self.group)
  
      def createitems(self, fill, text):
! 	self.__oval = Oval(self.canvas,
! 			   self.x-20, self.y-10, self.x+20, self.y+10,
! 			   fill=fill, width=3)
! 	self.group.addtag_withtag(self.__oval)
! 	self.__text = CanvasText(self.canvas,
! 			   self.x, self.y, text=text)
! 	self.group.addtag_withtag(self.__text)
  
      def moveby(self, dx, dy):
! 	if dx == dy == 0:
! 	    return
! 	self.group.move(dx, dy)
! 	self.x = self.x + dx
! 	self.y = self.y + dy
  
      def moveto(self, x, y):
! 	self.moveby(x - self.x, y - self.y)
  
      def transfer(self, pile):
! 	if self.pile:
! 	    self.pile.delete(self)
! 	    self.pile = None
! 	self.pile = pile
! 	if self.pile:
! 	    self.pile.add(self)
  
      def tkraise(self):
! 	self.group.tkraise()
  
  
--- 34,76 ----
  
      def __init__(self, canvas, x=0, y=0, fill='red', text='object'):
!         self.canvas = canvas
!         self.x = x
!         self.y = y
!         self.pile = None
!         self.group = Group(self.canvas)
!         self.createitems(fill, text)
  
      def __str__(self):
!         return str(self.group)
  
      def createitems(self, fill, text):
!         self.__oval = Oval(self.canvas,
!                            self.x-20, self.y-10, self.x+20, self.y+10,
!                            fill=fill, width=3)
!         self.group.addtag_withtag(self.__oval)
!         self.__text = CanvasText(self.canvas,
!                            self.x, self.y, text=text)
!         self.group.addtag_withtag(self.__text)
  
      def moveby(self, dx, dy):
!         if dx == dy == 0:
!             return
!         self.group.move(dx, dy)
!         self.x = self.x + dx
!         self.y = self.y + dy
  
      def moveto(self, x, y):
!         self.moveby(x - self.x, y - self.y)
  
      def transfer(self, pile):
!         if self.pile:
!             self.pile.delete(self)
!             self.pile = None
!         self.pile = pile
!         if self.pile:
!             self.pile.add(self)
  
      def tkraise(self):
!         self.group.tkraise()
  
  
***************
*** 80,87 ****
  
      def createitems(self, *args):
! 	self.__oval = Oval(self.canvas,
! 			   self.x-20, self.y-10, self.x+20, self.y+10,
! 			   fill='gray', outline='')
! 	self.group.addtag_withtag(self.__oval)
  
  
--- 80,87 ----
  
      def createitems(self, *args):
!         self.__oval = Oval(self.canvas,
!                            self.x-20, self.y-10, self.x+20, self.y+10,
!                            fill='gray', outline='')
!         self.group.addtag_withtag(self.__oval)
  
  
***************
*** 91,126 ****
  
      def __init__(self, canvas, x, y, tag=None):
! 	self.canvas = canvas
! 	self.x = x
! 	self.y = y
! 	self.objects = []
! 	self.bottom = Bottom(self.canvas, self.x, self.y)
! 	self.group = Group(self.canvas, tag=tag)
! 	self.group.addtag_withtag(self.bottom.group)
! 	self.bindhandlers()
  
      def bindhandlers(self):
! 	self.group.bind('<1>', self.clickhandler)
!  	self.group.bind('<Double-1>', self.doubleclickhandler)
  
      def add(self, object):
! 	self.objects.append(object)
! 	self.group.addtag_withtag(object.group)
! 	self.position(object)
  
      def delete(self, object):
! 	object.group.dtag(self.group)
! 	self.objects.remove(object)
  
      def position(self, object):
! 	object.tkraise()
! 	i = self.objects.index(object)
! 	object.moveto(self.x + i*4, self.y + i*8)
  
      def clickhandler(self, event):
! 	pass
  
      def doubleclickhandler(self, event):
! 	pass
  
  
--- 91,126 ----
  
      def __init__(self, canvas, x, y, tag=None):
!         self.canvas = canvas
!         self.x = x
!         self.y = y
!         self.objects = []
!         self.bottom = Bottom(self.canvas, self.x, self.y)
!         self.group = Group(self.canvas, tag=tag)
!         self.group.addtag_withtag(self.bottom.group)
!         self.bindhandlers()
  
      def bindhandlers(self):
!         self.group.bind('<1>', self.clickhandler)
!         self.group.bind('<Double-1>', self.doubleclickhandler)
  
      def add(self, object):
!         self.objects.append(object)
!         self.group.addtag_withtag(object.group)
!         self.position(object)
  
      def delete(self, object):
!         object.group.dtag(self.group)
!         self.objects.remove(object)
  
      def position(self, object):
!         object.tkraise()
!         i = self.objects.index(object)
!         object.moveto(self.x + i*4, self.y + i*8)
  
      def clickhandler(self, event):
!         pass
  
      def doubleclickhandler(self, event):
!         pass
  
  
***************
*** 128,174 ****
  
      def bindhandlers(self):
! 	Pile.bindhandlers(self)
! 	self.group.bind('<B1-Motion>', self.motionhandler)
! 	self.group.bind('<ButtonRelease-1>', self.releasehandler)
  
      movethis = None
  
      def clickhandler(self, event):
! 	tags = self.canvas.gettags('current')
! 	for i in range(len(self.objects)):
! 	    o = self.objects[i]
! 	    if o.group.tag in tags:
! 		break
! 	else:
! 	    self.movethis = None
! 	    return
! 	self.movethis = self.objects[i:]
! 	for o in self.movethis:
! 	    o.tkraise()
! 	self.lastx = event.x
! 	self.lasty = event.y
  
      doubleclickhandler = clickhandler
  
      def motionhandler(self, event):
! 	if not self.movethis:
! 	    return
! 	dx = event.x - self.lastx
! 	dy = event.y - self.lasty
! 	self.lastx = event.x
! 	self.lasty = event.y
! 	for o in self.movethis:
! 	    o.moveby(dx, dy)
  
      def releasehandler(self, event):
! 	objects = self.movethis
! 	if not objects:
! 	    return
! 	self.movethis = None
! 	self.finishmove(objects)
  
      def finishmove(self, objects):
! 	for o in objects:
! 	    self.position(o)
  
  
--- 128,174 ----
  
      def bindhandlers(self):
!         Pile.bindhandlers(self)
!         self.group.bind('<B1-Motion>', self.motionhandler)
!         self.group.bind('<ButtonRelease-1>', self.releasehandler)
  
      movethis = None
  
      def clickhandler(self, event):
!         tags = self.canvas.gettags('current')
!         for i in range(len(self.objects)):
!             o = self.objects[i]
!             if o.group.tag in tags:
!                 break
!         else:
!             self.movethis = None
!             return
!         self.movethis = self.objects[i:]
!         for o in self.movethis:
!             o.tkraise()
!         self.lastx = event.x
!         self.lasty = event.y
  
      doubleclickhandler = clickhandler
  
      def motionhandler(self, event):
!         if not self.movethis:
!             return
!         dx = event.x - self.lastx
!         dy = event.y - self.lasty
!         self.lastx = event.x
!         self.lasty = event.y
!         for o in self.movethis:
!             o.moveby(dx, dy)
  
      def releasehandler(self, event):
!         objects = self.movethis
!         if not objects:
!             return
!         self.movethis = None
!         self.finishmove(objects)
  
      def finishmove(self, objects):
!         for o in objects:
!             self.position(o)
  
  
***************
*** 180,206 ****
  
      def __init__(self, demo):
! 	self.demo = demo
! 	MovingPile.__init__(self, self.demo.canvas, self.x, self.y, self.tag)
  
      def doubleclickhandler(self, event):
! 	try:
! 	    o = self.objects[-1]
! 	except IndexError:
! 	    return
! 	o.transfer(self.other())
! 	MovingPile.doubleclickhandler(self, event)
  
      def other(self):
! 	return self.demo.p2
  
      def finishmove(self, objects):
! 	o = objects[0]
! 	p = self.other()
! 	x, y = o.x, o.y
! 	if (x-p.x)**2 + (y-p.y)**2 < (x-self.x)**2 + (y-self.y)**2:
! 	    for o in objects:
! 		o.transfer(p)
! 	else:
! 	    MovingPile.finishmove(self, objects)
  
  class Pile2(Pile1):
--- 180,206 ----
  
      def __init__(self, demo):
!         self.demo = demo
!         MovingPile.__init__(self, self.demo.canvas, self.x, self.y, self.tag)
  
      def doubleclickhandler(self, event):
!         try:
!             o = self.objects[-1]
!         except IndexError:
!             return
!         o.transfer(self.other())
!         MovingPile.doubleclickhandler(self, event)
  
      def other(self):
!         return self.demo.p2
  
      def finishmove(self, objects):
!         o = objects[0]
!         p = self.other()
!         x, y = o.x, o.y
!         if (x-p.x)**2 + (y-p.y)**2 < (x-self.x)**2 + (y-self.y)**2:
!             for o in objects:
!                 o.transfer(p)
!         else:
!             MovingPile.finishmove(self, objects)
  
  class Pile2(Pile1):
***************
*** 211,215 ****
  
      def other(self):
! 	return self.demo.p1
  
  
--- 211,215 ----
  
      def other(self):
!         return self.demo.p1
  
  
***************
*** 217,234 ****
  
      def __init__(self, master):
! 	self.master = master
! 	self.canvas = Canvas(master,
! 			     width=200, height=200,
! 			     background='yellow',
! 			     relief=SUNKEN, borderwidth=2)
! 	self.canvas.pack(expand=1, fill=BOTH)
! 	self.p1 = Pile1(self)
! 	self.p2 = Pile2(self)
! 	o1 = Object(self.canvas, fill='red', text='o1')
! 	o2 = Object(self.canvas, fill='green', text='o2')
! 	o3 = Object(self.canvas, fill='light blue', text='o3')
! 	o1.transfer(self.p1)
! 	o2.transfer(self.p1)
! 	o3.transfer(self.p2)
  
  
--- 217,234 ----
  
      def __init__(self, master):
!         self.master = master
!         self.canvas = Canvas(master,
!                              width=200, height=200,
!                              background='yellow',
!                              relief=SUNKEN, borderwidth=2)
!         self.canvas.pack(expand=1, fill=BOTH)
!         self.p1 = Pile1(self)
!         self.p2 = Pile2(self)
!         o1 = Object(self.canvas, fill='red', text='o1')
!         o2 = Object(self.canvas, fill='green', text='o2')
!         o3 = Object(self.canvas, fill='light blue', text='o3')
!         o1.transfer(self.p1)
!         o2.transfer(self.p1)
!         o3.transfer(self.p2)
  
  

Index: dialog.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/dialog.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** dialog.py	7 Oct 1997 14:37:58 -0000	1.6
--- dialog.py	18 Jul 2004 06:09:08 -0000	1.7
***************
*** 26,34 ****
  
      msg = Message(top, width='3i', text=text,
! 		  font='-Adobe-Times-Medium-R-Normal-*-180-*')
      msg.pack(side=RIGHT, expand=1, fill=BOTH, padx='3m', pady='3m')
      if bitmap:
! 	bm = Label(top, bitmap=bitmap)
! 	bm.pack(side=LEFT, padx='3m', pady='3m')
  
      # 3. Create a row of buttons at the bottom of the dialog.
--- 26,34 ----
  
      msg = Message(top, width='3i', text=text,
!                   font='-Adobe-Times-Medium-R-Normal-*-180-*')
      msg.pack(side=RIGHT, expand=1, fill=BOTH, padx='3m', pady='3m')
      if bitmap:
!         bm = Label(top, bitmap=bitmap)
!         bm.pack(side=LEFT, padx='3m', pady='3m')
  
      # 3. Create a row of buttons at the bottom of the dialog.
***************
*** 38,53 ****
      i = 0
      for but in args:
! 	b = Button(bot, text=but, command=lambda v=var,i=i: v.set(i))
! 	buttons.append(b)
! 	if i == default:
! 	    bd = Frame(bot, relief=SUNKEN, borderwidth=1)
! 	    bd.pack(side=LEFT, expand=1, padx='3m', pady='2m')
! 	    b.lift()
! 	    b.pack (in_=bd, side=LEFT,
! 		    padx='2m', pady='2m', ipadx='2m', ipady='1m')
! 	else:
! 	    b.pack (side=LEFT, expand=1,
! 		    padx='3m', pady='3m', ipadx='2m', ipady='1m')
! 	i = i+1
  
      # 4. Set up a binding for <Return>, if there's a default,
--- 38,53 ----
      i = 0
      for but in args:
!         b = Button(bot, text=but, command=lambda v=var,i=i: v.set(i))
!         buttons.append(b)
!         if i == default:
!             bd = Frame(bot, relief=SUNKEN, borderwidth=1)
!             bd.pack(side=LEFT, expand=1, padx='3m', pady='2m')
!             b.lift()
!             b.pack (in_=bd, side=LEFT,
!                     padx='2m', pady='2m', ipadx='2m', ipady='1m')
!         else:
!             b.pack (side=LEFT, expand=1,
!                     padx='3m', pady='3m', ipadx='2m', ipady='1m')
!         i = i+1
  
      # 4. Set up a binding for <Return>, if there's a default,
***************
*** 55,62 ****
  
      if default >= 0:
! 	w.bind('<Return>',
! 	       lambda e, b=buttons[default], v=var, i=default:
! 	       (b.flash(),
! 		v.set(i)))
  
      oldFocus = w.focus_get()
--- 55,62 ----
  
      if default >= 0:
!         w.bind('<Return>',
!                lambda e, b=buttons[default], v=var, i=default:
!                (b.flash(),
!                 v.set(i)))
  
      oldFocus = w.focus_get()
***************
*** 76,96 ****
  def go():
      i = dialog(mainWidget,
! 	       'Not Responding',
! 	       "The file server isn't responding right now; "
! 	       "I'll keep trying.",
! 	       '',
! 	       -1,
! 	       'OK')
      print 'pressed button', i
      i = dialog(mainWidget,
! 	       'File Modified',
! 	       'File "tcl.h" has been modified since '
! 	       'the last time it was saved. '
! 	       'Do you want to save it before exiting the application?',
! 	       'warning',
! 	       0,
! 	       'Save File',
! 	       'Discard Changes',
! 	       'Return To Editor')
      print 'pressed button', i
  
--- 76,96 ----
  def go():
      i = dialog(mainWidget,
!                'Not Responding',
!                "The file server isn't responding right now; "
!                "I'll keep trying.",
!                '',
!                -1,
!                'OK')
      print 'pressed button', i
      i = dialog(mainWidget,
!                'File Modified',
!                'File "tcl.h" has been modified since '
!                'the last time it was saved. '
!                'Do you want to save it before exiting the application?',
!                'warning',
!                0,
!                'Save File',
!                'Discard Changes',
!                'Return To Editor')
      print 'pressed button', i
  

Index: electrons.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/electrons.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** electrons.py	26 May 1998 21:43:44 -0000	1.9
--- electrons.py	18 Jul 2004 06:09:08 -0000	1.10
***************
*** 1,5 ****
  #! /usr/bin/env python
  
! # Simulate "electrons" migrating across the screen.  
  # An optional bitmap file in can be in the background.
  #
--- 1,5 ----
  #! /usr/bin/env python
  
! # Simulate "electrons" migrating across the screen.
  # An optional bitmap file in can be in the background.
  #
***************
*** 19,91 ****
  class Electrons:
  
! 	# Create our objects
! 	def __init__(self, n, bitmap = None):
! 		self.n = n
! 		self.tk = tk = Tk()
! 		self.canvas = c = Canvas(tk)
! 		c.pack()
! 		width, height = tk.getint(c['width']), tk.getint(c['height'])
  
! 		# Add background bitmap
! 		if bitmap:
! 			self.bitmap = c.create_bitmap(width/2, height/2,
! 						      bitmap=bitmap,
! 						      foreground='blue')
  
! 		self.pieces = []
! 		x1, y1, x2, y2 = 10,70,14,74
! 		for i in range(n):
! 			p = c.create_oval(x1, y1, x2, y2, fill='red')
! 			self.pieces.append(p)
! 			y1, y2 = y1 +2, y2 + 2
! 		self.tk.update()
  
! 	def random_move(self, n):
! 		c = self.canvas
! 		for p in self.pieces:
! 			x = random.choice(range(-2,4))
! 			y = random.choice(range(-3,4))
! 			c.move(p, x, y)
! 		self.tk.update()
  
! 	# Run -- allow 500 movemens
! 	def run(self):
! 		try:
! 			for i in range(500):
! 				self.random_move(self.n)
! 		except TclError:
! 			try:
! 				self.tk.destroy()
! 			except TclError:
! 				pass
  
  
  # Main program
  def main():
! 	import sys, string
  
! 	# First argument is number of electrons, default 30
! 	if sys.argv[1:]:
! 		n = string.atoi(sys.argv[1])
! 	else:
! 		n = 30
  
! 	# Second argument is bitmap file, default none
! 	if sys.argv[2:]:
! 		bitmap = sys.argv[2]
! 		# Reverse meaning of leading '@' compared to Tk
! 		if bitmap[0] == '@': bitmap = bitmap[1:]
! 		else: bitmap = '@' + bitmap
! 	else:
! 		bitmap = None
  
! 	# Create the graphical objects...
! 	h = Electrons(n, bitmap)
  
! 	# ...and run!
! 	h.run()
  
  
  # Call main when run as script
  if __name__ == '__main__':
! 	main()
--- 19,91 ----
  class Electrons:
  
!     # Create our objects
!     def __init__(self, n, bitmap = None):
!         self.n = n
!         self.tk = tk = Tk()
!         self.canvas = c = Canvas(tk)
!         c.pack()
!         width, height = tk.getint(c['width']), tk.getint(c['height'])
  
!         # Add background bitmap
!         if bitmap:
!             self.bitmap = c.create_bitmap(width/2, height/2,
!                                           bitmap=bitmap,
!                                           foreground='blue')
  
!         self.pieces = []
!         x1, y1, x2, y2 = 10,70,14,74
!         for i in range(n):
!             p = c.create_oval(x1, y1, x2, y2, fill='red')
!             self.pieces.append(p)
!             y1, y2 = y1 +2, y2 + 2
!         self.tk.update()
  
!     def random_move(self, n):
!         c = self.canvas
!         for p in self.pieces:
!             x = random.choice(range(-2,4))
!             y = random.choice(range(-3,4))
!             c.move(p, x, y)
!         self.tk.update()
  
!     # Run -- allow 500 movemens
!     def run(self):
!         try:
!             for i in range(500):
!                 self.random_move(self.n)
!         except TclError:
!             try:
!                 self.tk.destroy()
!             except TclError:
!                 pass
  
  
  # Main program
  def main():
!     import sys, string
  
!     # First argument is number of electrons, default 30
!     if sys.argv[1:]:
!         n = string.atoi(sys.argv[1])
!     else:
!         n = 30
  
!     # Second argument is bitmap file, default none
!     if sys.argv[2:]:
!         bitmap = sys.argv[2]
!         # Reverse meaning of leading '@' compared to Tk
!         if bitmap[0] == '@': bitmap = bitmap[1:]
!         else: bitmap = '@' + bitmap
!     else:
!         bitmap = None
  
!     # Create the graphical objects...
!     h = Electrons(n, bitmap)
  
!     # ...and run!
!     h.run()
  
  
  # Call main when run as script
  if __name__ == '__main__':
!     main()

Index: hanoi.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/hanoi.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** hanoi.py	22 Aug 1997 20:56:07 -0000	1.3
--- hanoi.py	18 Jul 2004 06:09:08 -0000	1.4
***************
*** 17,24 ****
  # as temporary.  For each move, call report()
  def hanoi(n, a, b, c, report):
! 	if n <= 0: return
! 	hanoi(n-1, a, c, b, report)
! 	report(n, a, b)
! 	hanoi(n-1, c, b, a, report)
  
  
--- 17,24 ----
  # as temporary.  For each move, call report()
  def hanoi(n, a, b, c, report):
!     if n <= 0: return
!     hanoi(n-1, a, c, b, report)
!     report(n, a, b)
!     hanoi(n-1, c, b, a, report)
  
  
***************
*** 26,154 ****
  class Tkhanoi:
  
! 	# Create our objects
! 	def __init__(self, n, bitmap = None):
! 		self.n = n
! 		self.tk = tk = Tk()
! 		self.canvas = c = Canvas(tk)
! 		c.pack()
! 		width, height = tk.getint(c['width']), tk.getint(c['height'])
  
! 		# Add background bitmap
! 		if bitmap:
! 			self.bitmap = c.create_bitmap(width/2, height/2,
! 						      bitmap=bitmap,
! 						      foreground='blue')
  
! 		# Generate pegs
! 		pegwidth = 10
! 		pegheight = height/2
! 		pegdist = width/3
! 		x1, y1 = (pegdist-pegwidth)/2, height*1/3
! 		x2, y2 = x1+pegwidth, y1+pegheight
! 		self.pegs = []
! 		p = c.create_rectangle(x1, y1, x2, y2, fill='black')
! 		self.pegs.append(p)
! 		x1, x2 = x1+pegdist, x2+pegdist
! 		p = c.create_rectangle(x1, y1, x2, y2, fill='black')
! 		self.pegs.append(p)
! 		x1, x2 = x1+pegdist, x2+pegdist
! 		p = c.create_rectangle(x1, y1, x2, y2, fill='black')
! 		self.pegs.append(p)
! 		self.tk.update()
  
! 		# Generate pieces
! 		pieceheight = pegheight/16
! 		maxpiecewidth = pegdist*2/3
! 		minpiecewidth = 2*pegwidth
! 		self.pegstate = [[], [], []]
! 		self.pieces = {}
! 		x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2
! 		x2, y2 = x1+maxpiecewidth, y1+pieceheight
! 		dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1))
! 		for i in range(n, 0, -1):
! 			p = c.create_rectangle(x1, y1, x2, y2, fill='red')
! 			self.pieces[i] = p
! 			self.pegstate[0].append(i)
! 			x1, x2 = x1 + dx, x2-dx
! 			y1, y2 = y1 - pieceheight-2, y2-pieceheight-2
! 			self.tk.update()
! 			self.tk.after(25)
  
! 	# Run -- never returns
! 	def run(self):
! 		while 1:
! 			hanoi(self.n, 0, 1, 2, self.report)
! 			hanoi(self.n, 1, 2, 0, self.report)
! 			hanoi(self.n, 2, 0, 1, self.report)
! 			hanoi(self.n, 0, 2, 1, self.report)
! 			hanoi(self.n, 2, 1, 0, self.report)
! 			hanoi(self.n, 1, 0, 2, self.report)
  
! 	# Reporting callback for the actual hanoi function
! 	def report(self, i, a, b):
! 		if self.pegstate[a][-1] != i: raise RuntimeError # Assertion
! 		del self.pegstate[a][-1]
! 		p = self.pieces[i]
! 		c = self.canvas
  
! 		# Lift the piece above peg a
! 		ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a])
! 		while 1:
! 			x1, y1, x2, y2 = c.bbox(p)
! 			if y2 < ay1: break
! 			c.move(p, 0, -1)
! 			self.tk.update()
  
! 		# Move it towards peg b
! 		bx1, by1, bx2, by2 = c.bbox(self.pegs[b])
! 		newcenter = (bx1+bx2)/2
! 		while 1:
! 			x1, y1, x2, y2 = c.bbox(p)
! 			center = (x1+x2)/2
! 			if center == newcenter: break
! 			if center > newcenter: c.move(p, -1, 0)
! 			else: c.move(p, 1, 0)
! 			self.tk.update()
  
! 		# Move it down on top of the previous piece
! 		pieceheight = y2-y1
! 		newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2
! 		while 1:
! 			x1, y1, x2, y2 = c.bbox(p)
! 			if y2 >= newbottom: break
! 			c.move(p, 0, 1)
! 			self.tk.update()
  
! 		# Update peg state
! 		self.pegstate[b].append(i)
  
  
  # Main program
  def main():
! 	import sys, string
  
! 	# First argument is number of pegs, default 4
! 	if sys.argv[1:]:
! 		n = string.atoi(sys.argv[1])
! 	else:
! 		n = 4
  
! 	# Second argument is bitmap file, default none
! 	if sys.argv[2:]:
! 		bitmap = sys.argv[2]
! 		# Reverse meaning of leading '@' compared to Tk
! 		if bitmap[0] == '@': bitmap = bitmap[1:]
! 		else: bitmap = '@' + bitmap
! 	else:
! 		bitmap = None
  
! 	# Create the graphical objects...
! 	h = Tkhanoi(n, bitmap)
  
! 	# ...and run!
! 	h.run()
  
  
  # Call main when run as script
  if __name__ == '__main__':
! 	main()
--- 26,154 ----
  class Tkhanoi:
  
!     # Create our objects
!     def __init__(self, n, bitmap = None):
!         self.n = n
!         self.tk = tk = Tk()
!         self.canvas = c = Canvas(tk)
!         c.pack()
!         width, height = tk.getint(c['width']), tk.getint(c['height'])
  
!         # Add background bitmap
!         if bitmap:
!             self.bitmap = c.create_bitmap(width/2, height/2,
!                                           bitmap=bitmap,
!                                           foreground='blue')
  
!         # Generate pegs
!         pegwidth = 10
!         pegheight = height/2
!         pegdist = width/3
!         x1, y1 = (pegdist-pegwidth)/2, height*1/3
!         x2, y2 = x1+pegwidth, y1+pegheight
!         self.pegs = []
!         p = c.create_rectangle(x1, y1, x2, y2, fill='black')
!         self.pegs.append(p)
!         x1, x2 = x1+pegdist, x2+pegdist
!         p = c.create_rectangle(x1, y1, x2, y2, fill='black')
!         self.pegs.append(p)
!         x1, x2 = x1+pegdist, x2+pegdist
!         p = c.create_rectangle(x1, y1, x2, y2, fill='black')
!         self.pegs.append(p)
!         self.tk.update()
  
!         # Generate pieces
!         pieceheight = pegheight/16
!         maxpiecewidth = pegdist*2/3
!         minpiecewidth = 2*pegwidth
!         self.pegstate = [[], [], []]
!         self.pieces = {}
!         x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2
!         x2, y2 = x1+maxpiecewidth, y1+pieceheight
!         dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1))
!         for i in range(n, 0, -1):
!             p = c.create_rectangle(x1, y1, x2, y2, fill='red')
!             self.pieces[i] = p
!             self.pegstate[0].append(i)
!             x1, x2 = x1 + dx, x2-dx
!             y1, y2 = y1 - pieceheight-2, y2-pieceheight-2
!             self.tk.update()
!             self.tk.after(25)
  
!     # Run -- never returns
!     def run(self):
!         while 1:
!             hanoi(self.n, 0, 1, 2, self.report)
!             hanoi(self.n, 1, 2, 0, self.report)
!             hanoi(self.n, 2, 0, 1, self.report)
!             hanoi(self.n, 0, 2, 1, self.report)
!             hanoi(self.n, 2, 1, 0, self.report)
!             hanoi(self.n, 1, 0, 2, self.report)
  
!     # Reporting callback for the actual hanoi function
!     def report(self, i, a, b):
!         if self.pegstate[a][-1] != i: raise RuntimeError # Assertion
!         del self.pegstate[a][-1]
!         p = self.pieces[i]
!         c = self.canvas
  
!         # Lift the piece above peg a
!         ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a])
!         while 1:
!             x1, y1, x2, y2 = c.bbox(p)
!             if y2 < ay1: break
!             c.move(p, 0, -1)
!             self.tk.update()
  
!         # Move it towards peg b
!         bx1, by1, bx2, by2 = c.bbox(self.pegs[b])
!         newcenter = (bx1+bx2)/2
!         while 1:
!             x1, y1, x2, y2 = c.bbox(p)
!             center = (x1+x2)/2
!             if center == newcenter: break
!             if center > newcenter: c.move(p, -1, 0)
!             else: c.move(p, 1, 0)
!             self.tk.update()
  
!         # Move it down on top of the previous piece
!         pieceheight = y2-y1
!         newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2
!         while 1:
!             x1, y1, x2, y2 = c.bbox(p)
!             if y2 >= newbottom: break
!             c.move(p, 0, 1)
!             self.tk.update()
  
!         # Update peg state
!         self.pegstate[b].append(i)
  
  
  # Main program
  def main():
!     import sys, string
  
!     # First argument is number of pegs, default 4
!     if sys.argv[1:]:
!         n = string.atoi(sys.argv[1])
!     else:
!         n = 4
  
!     # Second argument is bitmap file, default none
!     if sys.argv[2:]:
!         bitmap = sys.argv[2]
!         # Reverse meaning of leading '@' compared to Tk
!         if bitmap[0] == '@': bitmap = bitmap[1:]
!         else: bitmap = '@' + bitmap
!     else:
!         bitmap = None
  
!     # Create the graphical objects...
!     h = Tkhanoi(n, bitmap)
  
!     # ...and run!
!     h.run()
  
  
  # Call main when run as script
  if __name__ == '__main__':
!     main()

Index: hello.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/hello.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hello.py	10 Apr 1995 11:46:37 -0000	1.1
--- hello.py	18 Jul 2004 06:09:08 -0000	1.2
***************
*** 5,17 ****
  
  def main():
! 	root = Tk()
! 	button = Button(root)
! 	button['text'] = 'Hello, world'
! 	button['command'] = quit_callback	# See below
! 	button.pack()
! 	root.mainloop()
  
  def quit_callback():
! 	sys.exit(0)
  
  main()
--- 5,17 ----
  
  def main():
!     root = Tk()
!     button = Button(root)
!     button['text'] = 'Hello, world'
!     button['command'] = quit_callback       # See below
!     button.pack()
!     root.mainloop()
  
  def quit_callback():
!     sys.exit(0)
  
  main()

Index: kill.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/kill.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** kill.py	27 Nov 1996 19:51:26 -0000	1.5
--- kill.py	18 Jul 2004 06:09:08 -0000	1.6
***************
*** 9,99 ****
  
  class BarButton(Menubutton):
! 	def __init__(self, master=None, **cnf):
! 		apply(Menubutton.__init__, (self, master), cnf)
! 		self.pack(side=LEFT)
! 		self.menu = Menu(self, name='menu')
! 		self['menu'] = self.menu
  
  class Kill(Frame):
! 	# List of (name, option, pid_column)
! 	format_list = [('Default', '', 0),
! 		       ('Long', '-l', 2),
! 		       ('User', '-u', 1),
! 		       ('Jobs', '-j', 1),
! 		       ('Signal', '-s', 1),
! 		       ('Memory', '-m', 0),
! 		       ('VM', '-v', 0),
! 		       ('Hex', '-X', 0)]
! 	def kill(self, selected):
! 		c = self.format_list[self.format.get()][2]
! 		pid = split(selected)[c]
! 		os.system('kill -9 ' + pid)
! 		self.do_update()
! 	def do_update(self):
! 		name, option, column = self.format_list[self.format.get()]
! 		s = commands.getoutput('ps -w ' + option)
! 		list = splitfields(s, '\n')
! 		self.header.set(list[0])
! 		del list[0]
! 		y = self.frame.vscroll.get()[0]
! 		self.frame.list.delete(0, AtEnd())
! 		for line in list:
! 			self.frame.list.insert(0, line)
! 		self.frame.list.yview(int(y))
! 	def do_motion(self, e):
! 		e.widget.select_clear(0, END)
! 		e.widget.select_set(e.widget.nearest(e.y))
! 	def do_leave(self, e):
! 		e.widget.select_clear(0, END)
! 	def do_1(self, e):
! 		self.kill(e.widget.get(e.widget.nearest(e.y)))
! 	def __init__(self, master=None, **cnf):
! 		Frame.__init__(self, master, cnf)
! 		self.pack(expand=1, fill=BOTH)
! 		self.bar = Frame(self, name='bar', relief=RAISED,
! 				 borderwidth=2)
! 		self.bar.pack(fill=X)
! 		self.bar.file = BarButton(self.bar, text='File')
! 		self.bar.file.menu.add_command(
! 			label='Quit', command=self.quit)
! 		self.bar.view = BarButton(self.bar, text='View')
! 		self.format = IntVar(self)
! 		self.format.set(2)
! 		for num in range(len(self.format_list)):
! 			self.bar.view.menu.add_radiobutton(
! 				label=self.format_list[num][0], 
! 				command=self.do_update,
! 				variable=self.format,
! 				value=num)
! 		#self.bar.view.menu.add_separator()
! 		#XXX ...
! 		self.bar.tk_menuBar(self.bar.file, self.bar.view)
! 		self.frame = Frame(self, relief=RAISED, borderwidth=2)
! 		self.frame.pack(expand=1, fill=BOTH)
! 		self.header = StringVar(self)
! 		self.frame.label = Label(self.frame, relief=FLAT, anchor=NW,
! 					 borderwidth=0,
! 					 textvariable=self.header)
! 		self.frame.label.pack(fill=X)
! 		self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL)
! 		self.frame.list = Listbox(self.frame, relief=SUNKEN,
! 					  selectbackground='#eed5b7',
! 					  selectborderwidth=0,
! 					  yscroll=self.frame.vscroll.set)
! 		self.frame.vscroll['command'] = self.frame.list.yview
! 		self.frame.vscroll.pack(side=RIGHT, fill=Y)
! 		self.frame.list.pack(expand=1, fill=BOTH)
! 		self.update = Button(self, text="Update",
! 				     command=self.do_update)
! 		self.update.pack(expand=1, fill=X)
! 		self.frame.list.bind('<Motion>', self.do_motion)
! 		self.frame.list.bind('<Leave>', self.do_leave)
! 		self.frame.list.bind('<1>', self.do_1)
! 		self.do_update()
  
  if __name__ == '__main__':
! 	kill = Kill(None, borderwidth=5)
! 	kill.winfo_toplevel().title('Tkinter Process Killer')
! 	kill.winfo_toplevel().minsize(1, 1)
! 	kill.mainloop()
! 
--- 9,98 ----
  
  class BarButton(Menubutton):
!     def __init__(self, master=None, **cnf):
!         apply(Menubutton.__init__, (self, master), cnf)
!         self.pack(side=LEFT)
!         self.menu = Menu(self, name='menu')
!         self['menu'] = self.menu
  
  class Kill(Frame):
!     # List of (name, option, pid_column)
!     format_list = [('Default', '', 0),
!                    ('Long', '-l', 2),
!                    ('User', '-u', 1),
!                    ('Jobs', '-j', 1),
!                    ('Signal', '-s', 1),
!                    ('Memory', '-m', 0),
!                    ('VM', '-v', 0),
!                    ('Hex', '-X', 0)]
!     def kill(self, selected):
!         c = self.format_list[self.format.get()][2]
!         pid = split(selected)[c]
!         os.system('kill -9 ' + pid)
!         self.do_update()
!     def do_update(self):
!         name, option, column = self.format_list[self.format.get()]
!         s = commands.getoutput('ps -w ' + option)
!         list = splitfields(s, '\n')
!         self.header.set(list[0])
!         del list[0]
!         y = self.frame.vscroll.get()[0]
!         self.frame.list.delete(0, AtEnd())
!         for line in list:
!             self.frame.list.insert(0, line)
!         self.frame.list.yview(int(y))
!     def do_motion(self, e):
!         e.widget.select_clear(0, END)
!         e.widget.select_set(e.widget.nearest(e.y))
!     def do_leave(self, e):
!         e.widget.select_clear(0, END)
!     def do_1(self, e):
!         self.kill(e.widget.get(e.widget.nearest(e.y)))
!     def __init__(self, master=None, **cnf):
!         Frame.__init__(self, master, cnf)
!         self.pack(expand=1, fill=BOTH)
!         self.bar = Frame(self, name='bar', relief=RAISED,
!                          borderwidth=2)
!         self.bar.pack(fill=X)
!         self.bar.file = BarButton(self.bar, text='File')
!         self.bar.file.menu.add_command(
!                 label='Quit', command=self.quit)
!         self.bar.view = BarButton(self.bar, text='View')
!         self.format = IntVar(self)
!         self.format.set(2)
!         for num in range(len(self.format_list)):
!             self.bar.view.menu.add_radiobutton(
!                     label=self.format_list[num][0],
!                     command=self.do_update,
!                     variable=self.format,
!                     value=num)
!         #self.bar.view.menu.add_separator()
!         #XXX ...
!         self.bar.tk_menuBar(self.bar.file, self.bar.view)
!         self.frame = Frame(self, relief=RAISED, borderwidth=2)
!         self.frame.pack(expand=1, fill=BOTH)
!         self.header = StringVar(self)
!         self.frame.label = Label(self.frame, relief=FLAT, anchor=NW,
!                                  borderwidth=0,
!                                  textvariable=self.header)
!         self.frame.label.pack(fill=X)
!         self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL)
!         self.frame.list = Listbox(self.frame, relief=SUNKEN,
!                                   selectbackground='#eed5b7',
!                                   selectborderwidth=0,
!                                   yscroll=self.frame.vscroll.set)
!         self.frame.vscroll['command'] = self.frame.list.yview
!         self.frame.vscroll.pack(side=RIGHT, fill=Y)
!         self.frame.list.pack(expand=1, fill=BOTH)
!         self.update = Button(self, text="Update",
!                              command=self.do_update)
!         self.update.pack(expand=1, fill=X)
!         self.frame.list.bind('<Motion>', self.do_motion)
!         self.frame.list.bind('<Leave>', self.do_leave)
!         self.frame.list.bind('<1>', self.do_1)
!         self.do_update()
  
  if __name__ == '__main__':
!     kill = Kill(None, borderwidth=5)
!     kill.winfo_toplevel().title('Tkinter Process Killer')
!     kill.winfo_toplevel().minsize(1, 1)
!     kill.mainloop()

Index: listtree.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/listtree.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** listtree.py	30 Jul 1996 18:56:11 -0000	1.3
--- listtree.py	18 Jul 2004 06:09:08 -0000	1.4
***************
*** 7,37 ****
  
  def listtree(master, app):
! 	list = Listbox(master, name='list')
! 	list.pack(expand=1, fill=BOTH)
! 	listnodes(list, app, '.', 0)
! 	return list
  
  def listnodes(list, app, widget, level):
! 	klass = list.send(app, 'winfo', 'class', widget)
! ##	i = string.rindex(widget, '.')
! ##	list.insert(END, '%s%s (%s)' % ((level-1)*'.   ', widget[i:], klass))
! 	list.insert(END, '%s (%s)' % (widget, klass))
! 	children = list.tk.splitlist(
! 		list.send(app, 'winfo', 'children', widget))
! 	for c in children:
! 		listnodes(list, app, c, level+1)
  
  def main():
! 	if not sys.argv[1:]:
! 		sys.stderr.write('Usage: listtree appname\n')
! 		sys.exit(2)
! 	app = sys.argv[1]
! 	tk = Tk()
! 	tk.minsize(1, 1)
! 	f = Frame(tk, name='f')
! 	f.pack(expand=1, fill=BOTH)
! 	list = listtree(f, app)
! 	tk.mainloop()
  
  if __name__ == '__main__':
! 	main()
--- 7,37 ----
  
  def listtree(master, app):
!     list = Listbox(master, name='list')
!     list.pack(expand=1, fill=BOTH)
!     listnodes(list, app, '.', 0)
!     return list
  
  def listnodes(list, app, widget, level):
!     klass = list.send(app, 'winfo', 'class', widget)
! ##      i = string.rindex(widget, '.')
! ##      list.insert(END, '%s%s (%s)' % ((level-1)*'.   ', widget[i:], klass))
!     list.insert(END, '%s (%s)' % (widget, klass))
!     children = list.tk.splitlist(
!             list.send(app, 'winfo', 'children', widget))
!     for c in children:
!         listnodes(list, app, c, level+1)
  
  def main():
!     if not sys.argv[1:]:
!         sys.stderr.write('Usage: listtree appname\n')
!         sys.exit(2)
!     app = sys.argv[1]
!     tk = Tk()
!     tk.minsize(1, 1)
!     f = Frame(tk, name='f')
!     f.pack(expand=1, fill=BOTH)
!     list = listtree(f, app)
!     tk.mainloop()
  
  if __name__ == '__main__':
!     main()

Index: mbox.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/mbox.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** mbox.py	12 Feb 2004 17:35:04 -0000	1.5
--- mbox.py	18 Jul 2004 06:09:08 -0000	1.6
***************
*** 17,285 ****
  
  def main():
! 	global root, tk, top, mid, bot
! 	global folderbox, foldermenu, scanbox, scanmenu, viewer
! 	global folder, seq
! 	global mh, mhf
  
! 	# Parse command line options
  
! 	folder = 'inbox'
! 	seq = 'all'
! 	try:
! 		opts, args = getopt.getopt(sys.argv[1:], '')
! 	except getopt.error, msg:
! 		print msg
! 		sys.exit(2)
! 	for arg in args:
! 		if arg[:1] == '+':
! 			folder = arg[1:]
! 		else:
! 			seq = arg
  
! 	# Initialize MH
  
! 	mh = mhlib.MH()
! 	mhf = mh.openfolder(folder)
  
! 	# Build widget hierarchy
  
! 	root = Tk()
! 	tk = root.tk
  
! 	top = Frame(root)
! 	top.pack({'expand': 1, 'fill': 'both'})
  
! 	# Build right part: folder list
  
! 	right = Frame(top)
! 	right.pack({'fill': 'y', 'side': 'right'})
  
! 	folderbar = Scrollbar(right, {'relief': 'sunken', 'bd': 2})
! 	folderbar.pack({'fill': 'y', 'side': 'right'})
  
! 	folderbox = Listbox(right, {'exportselection': 0})
! 	folderbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'})
  
! 	foldermenu = Menu(root)
! 	foldermenu.add('command',
! 		       {'label': 'Open Folder',
! 			'command': open_folder})
! 	foldermenu.add('separator')
! 	foldermenu.add('command',
! 		       {'label': 'Quit',
! 			'command': 'exit'})
! 	foldermenu.bind('<ButtonRelease-3>', folder_unpost)
  
! 	folderbox['yscrollcommand'] = (folderbar, 'set')
! 	folderbar['command'] = (folderbox, 'yview')
! 	folderbox.bind('<Double-1>', open_folder, 1)
! 	folderbox.bind('<3>', folder_post)
  
! 	# Build left part: scan list
  
! 	left = Frame(top)
! 	left.pack({'expand': 1, 'fill': 'both', 'side': 'left'})
  
! 	scanbar = Scrollbar(left, {'relief': 'sunken', 'bd': 2})
! 	scanbar.pack({'fill': 'y', 'side': 'right'})
  
! 	scanbox = Listbox(left, {'font': 'fixed'})
! 	scanbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'})
  
! 	scanmenu = Menu(root)
! 	scanmenu.add('command',
! 		     {'label': 'Open Message',
! 		      'command': open_message})
! 	scanmenu.add('command',
! 		     {'label': 'Remove Message',
! 		      'command': remove_message})
! 	scanmenu.add('command',
! 		     {'label': 'Refile Message',
! 		      'command': refile_message})
! 	scanmenu.add('separator')
! 	scanmenu.add('command',
! 		     {'label': 'Quit',
! 		      'command': 'exit'})
! 	scanmenu.bind('<ButtonRelease-3>', scan_unpost)
  
! 	scanbox['yscrollcommand'] = (scanbar, 'set')
! 	scanbar['command'] = (scanbox, 'yview')
! 	scanbox.bind('<Double-1>', open_message)
! 	scanbox.bind('<3>', scan_post)
  
! 	# Separator between middle and bottom part
  
! 	rule2 = Frame(root, {'bg': 'black'})
! 	rule2.pack({'fill': 'x'})
  
! 	# Build bottom part: current message
  
! 	bot = Frame(root)
! 	bot.pack({'expand': 1, 'fill': 'both'})
! 	#
! 	viewer = None
  
! 	# Window manager commands
  
! 	root.minsize(800, 1) # Make window resizable
  
! 	# Fill folderbox with text
  
! 	setfolders()
  
! 	# Fill scanbox with text
  
! 	rescan()
  
! 	# Enter mainloop
  
! 	root.mainloop()
  
  def folder_post(e):
! 	x, y = e.x_root, e.y_root
! 	foldermenu.post(x - 10, y - 10)
! 	foldermenu.grab_set()
  
  def folder_unpost(e):
! 	tk.call('update', 'idletasks')
! 	foldermenu.grab_release()
! 	foldermenu.unpost()
! 	foldermenu.invoke('active')
  
  def scan_post(e):
! 	x, y = e.x_root, e.y_root
! 	scanmenu.post(x - 10, y - 10)
! 	scanmenu.grab_set()
  
  def scan_unpost(e):
! 	tk.call('update', 'idletasks')
! 	scanmenu.grab_release()
! 	scanmenu.unpost()
! 	scanmenu.invoke('active')
  
  scanparser = regex.compile('^ *\([0-9]+\)')
  
  def open_folder(e=None):
! 	global folder, mhf
! 	sel = folderbox.curselection()
! 	if len(sel) != 1:
! 		if len(sel) > 1:
! 			msg = "Please open one folder at a time"
! 		else:
! 			msg = "Please select a folder to open"
! 		dialog(root, "Can't Open Folder", msg, "", 0, "OK")
! 		return
! 	i = sel[0]
! 	folder = folderbox.get(i)
! 	mhf = mh.openfolder(folder)
! 	rescan()
  
  def open_message(e=None):
! 	global viewer
! 	sel = scanbox.curselection()
! 	if len(sel) != 1:
! 		if len(sel) > 1:
! 			msg = "Please open one message at a time"
! 		else:
! 			msg = "Please select a message to open"
! 		dialog(root, "Can't Open Message", msg, "", 0, "OK")
! 		return
! 	cursor = scanbox['cursor']
! 	scanbox['cursor'] = 'watch'
! 	tk.call('update', 'idletasks')
! 	i = sel[0]
! 	line = scanbox.get(i)
! 	if scanparser.match(line) >= 0:
! 		num = string.atoi(scanparser.group(1))
! 		m = mhf.openmessage(num)
! 		if viewer: viewer.destroy()
! 		from MimeViewer import MimeViewer
! 		viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m)
! 		viewer.pack()
! 		viewer.show()
! 	scanbox['cursor'] = cursor
  
  def interestingheader(header):
! 	return header != 'received'
  
  def remove_message(e=None):
! 	itop = scanbox.nearest(0)
! 	sel = scanbox.curselection()
! 	if not sel:
! 		dialog(root, "No Message To Remove",
! 		       "Please select a message to remove", "", 0, "OK")
! 		return
! 	todo = []
! 	for i in sel:
! 		line = scanbox.get(i)
! 		if scanparser.match(line) >= 0:
! 			todo.append(string.atoi(scanparser.group(1)))
! 	mhf.removemessages(todo)
! 	rescan()
! 	fixfocus(min(todo), itop)
  
  lastrefile = ''
  tofolder = None
  def refile_message(e=None):
! 	global lastrefile, tofolder
! 	itop = scanbox.nearest(0)
! 	sel = scanbox.curselection()
! 	if not sel:
! 		dialog(root, "No Message To Refile",
! 		       "Please select a message to refile", "", 0, "OK")
! 		return
! 	foldersel = folderbox.curselection()
! 	if len(foldersel) != 1:
! 		if not foldersel:
! 			msg = "Please select a folder to refile to"
! 		else:
! 			msg = "Please select exactly one folder to refile to"
! 		dialog(root, "No Folder To Refile", msg, "", 0, "OK")
! 		return
! 	refileto = folderbox.get(foldersel[0])
! 	todo = []
! 	for i in sel:
! 		line = scanbox.get(i)
! 		if scanparser.match(line) >= 0:
! 			todo.append(string.atoi(scanparser.group(1)))
! 	if lastrefile != refileto or not tofolder:
! 		lastrefile = refileto
! 		tofolder = None
! 		tofolder = mh.openfolder(lastrefile)
! 	mhf.refilemessages(todo, tofolder)
! 	rescan()
! 	fixfocus(min(todo), itop)
  
  def fixfocus(near, itop):
! 	n = scanbox.size()
! 	for i in range(n):
! 		line = scanbox.get(repr(i))
! 		if scanparser.match(line) >= 0:
! 			num = string.atoi(scanparser.group(1))
! 			if num >= near:
! 				break
! 	else:
! 		i = 'end'
! 	scanbox.select_from(i)
! 	scanbox.yview(itop)
  
  def setfolders():
! 	folderbox.delete(0, 'end')
! 	for fn in mh.listallfolders():
! 		folderbox.insert('end', fn)
  
  def rescan():
! 	global viewer
! 	if viewer:
! 		viewer.destroy()
! 		viewer = None
! 	scanbox.delete(0, 'end')
! 	for line in scanfolder(folder, seq):
! 		scanbox.insert('end', line)
  
  def scanfolder(folder = 'inbox', sequence = 'all'):
! 	return map(
! 		lambda line: line[:-1],
! 		os.popen('scan +%s %s' % (folder, sequence), 'r').readlines())
  
  main()
--- 17,285 ----
  
  def main():
!     global root, tk, top, mid, bot
!     global folderbox, foldermenu, scanbox, scanmenu, viewer
!     global folder, seq
!     global mh, mhf
  
!     # Parse command line options
  
!     folder = 'inbox'
!     seq = 'all'
!     try:
!         opts, args = getopt.getopt(sys.argv[1:], '')
!     except getopt.error, msg:
!         print msg
!         sys.exit(2)
!     for arg in args:
!         if arg[:1] == '+':
!             folder = arg[1:]
!         else:
!             seq = arg
  
!     # Initialize MH
  
!     mh = mhlib.MH()
!     mhf = mh.openfolder(folder)
  
!     # Build widget hierarchy
  
!     root = Tk()
!     tk = root.tk
  
!     top = Frame(root)
!     top.pack({'expand': 1, 'fill': 'both'})
  
!     # Build right part: folder list
  
!     right = Frame(top)
!     right.pack({'fill': 'y', 'side': 'right'})
  
!     folderbar = Scrollbar(right, {'relief': 'sunken', 'bd': 2})
!     folderbar.pack({'fill': 'y', 'side': 'right'})
  
!     folderbox = Listbox(right, {'exportselection': 0})
!     folderbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'})
  
!     foldermenu = Menu(root)
!     foldermenu.add('command',
!                    {'label': 'Open Folder',
!                     'command': open_folder})
!     foldermenu.add('separator')
!     foldermenu.add('command',
!                    {'label': 'Quit',
!                     'command': 'exit'})
!     foldermenu.bind('<ButtonRelease-3>', folder_unpost)
  
!     folderbox['yscrollcommand'] = (folderbar, 'set')
!     folderbar['command'] = (folderbox, 'yview')
!     folderbox.bind('<Double-1>', open_folder, 1)
!     folderbox.bind('<3>', folder_post)
  
!     # Build left part: scan list
  
!     left = Frame(top)
!     left.pack({'expand': 1, 'fill': 'both', 'side': 'left'})
  
!     scanbar = Scrollbar(left, {'relief': 'sunken', 'bd': 2})
!     scanbar.pack({'fill': 'y', 'side': 'right'})
  
!     scanbox = Listbox(left, {'font': 'fixed'})
!     scanbox.pack({'expand': 1, 'fill': 'both', 'side': 'left'})
  
!     scanmenu = Menu(root)
!     scanmenu.add('command',
!                  {'label': 'Open Message',
!                   'command': open_message})
!     scanmenu.add('command',
!                  {'label': 'Remove Message',
!                   'command': remove_message})
!     scanmenu.add('command',
!                  {'label': 'Refile Message',
!                   'command': refile_message})
!     scanmenu.add('separator')
!     scanmenu.add('command',
!                  {'label': 'Quit',
!                   'command': 'exit'})
!     scanmenu.bind('<ButtonRelease-3>', scan_unpost)
  
!     scanbox['yscrollcommand'] = (scanbar, 'set')
!     scanbar['command'] = (scanbox, 'yview')
!     scanbox.bind('<Double-1>', open_message)
!     scanbox.bind('<3>', scan_post)
  
!     # Separator between middle and bottom part
  
!     rule2 = Frame(root, {'bg': 'black'})
!     rule2.pack({'fill': 'x'})
  
!     # Build bottom part: current message
  
!     bot = Frame(root)
!     bot.pack({'expand': 1, 'fill': 'both'})
!     #
!     viewer = None
  
!     # Window manager commands
  
!     root.minsize(800, 1) # Make window resizable
  
!     # Fill folderbox with text
  
!     setfolders()
  
!     # Fill scanbox with text
  
!     rescan()
  
!     # Enter mainloop
  
!     root.mainloop()
  
  def folder_post(e):
!     x, y = e.x_root, e.y_root
!     foldermenu.post(x - 10, y - 10)
!     foldermenu.grab_set()
  
  def folder_unpost(e):
!     tk.call('update', 'idletasks')
!     foldermenu.grab_release()
!     foldermenu.unpost()
!     foldermenu.invoke('active')
  
  def scan_post(e):
!     x, y = e.x_root, e.y_root
!     scanmenu.post(x - 10, y - 10)
!     scanmenu.grab_set()
  
  def scan_unpost(e):
!     tk.call('update', 'idletasks')
!     scanmenu.grab_release()
!     scanmenu.unpost()
!     scanmenu.invoke('active')
  
  scanparser = regex.compile('^ *\([0-9]+\)')
  
  def open_folder(e=None):
!     global folder, mhf
!     sel = folderbox.curselection()
!     if len(sel) != 1:
!         if len(sel) > 1:
!             msg = "Please open one folder at a time"
!         else:
!             msg = "Please select a folder to open"
!         dialog(root, "Can't Open Folder", msg, "", 0, "OK")
!         return
!     i = sel[0]
!     folder = folderbox.get(i)
!     mhf = mh.openfolder(folder)
!     rescan()
  
  def open_message(e=None):
!     global viewer
!     sel = scanbox.curselection()
!     if len(sel) != 1:
!         if len(sel) > 1:
!             msg = "Please open one message at a time"
!         else:
!             msg = "Please select a message to open"
!         dialog(root, "Can't Open Message", msg, "", 0, "OK")
!         return
!     cursor = scanbox['cursor']
!     scanbox['cursor'] = 'watch'
!     tk.call('update', 'idletasks')
!     i = sel[0]
!     line = scanbox.get(i)
!     if scanparser.match(line) >= 0:
!         num = string.atoi(scanparser.group(1))
!         m = mhf.openmessage(num)
!         if viewer: viewer.destroy()
!         from MimeViewer import MimeViewer
!         viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m)
!         viewer.pack()
!         viewer.show()
!     scanbox['cursor'] = cursor
  
  def interestingheader(header):
!     return header != 'received'
  
  def remove_message(e=None):
!     itop = scanbox.nearest(0)
!     sel = scanbox.curselection()
!     if not sel:
!         dialog(root, "No Message To Remove",
!                "Please select a message to remove", "", 0, "OK")
!         return
!     todo = []
!     for i in sel:
!         line = scanbox.get(i)
!         if scanparser.match(line) >= 0:
!             todo.append(string.atoi(scanparser.group(1)))
!     mhf.removemessages(todo)
!     rescan()
!     fixfocus(min(todo), itop)
  
  lastrefile = ''
  tofolder = None
  def refile_message(e=None):
!     global lastrefile, tofolder
!     itop = scanbox.nearest(0)
!     sel = scanbox.curselection()
!     if not sel:
!         dialog(root, "No Message To Refile",
!                "Please select a message to refile", "", 0, "OK")
!         return
!     foldersel = folderbox.curselection()
!     if len(foldersel) != 1:
!         if not foldersel:
!             msg = "Please select a folder to refile to"
!         else:
!             msg = "Please select exactly one folder to refile to"
!         dialog(root, "No Folder To Refile", msg, "", 0, "OK")
!         return
!     refileto = folderbox.get(foldersel[0])
!     todo = []
!     for i in sel:
!         line = scanbox.get(i)
!         if scanparser.match(line) >= 0:
!             todo.append(string.atoi(scanparser.group(1)))
!     if lastrefile != refileto or not tofolder:
!         lastrefile = refileto
!         tofolder = None
!         tofolder = mh.openfolder(lastrefile)
!     mhf.refilemessages(todo, tofolder)
!     rescan()
!     fixfocus(min(todo), itop)
  
  def fixfocus(near, itop):
!     n = scanbox.size()
!     for i in range(n):
!         line = scanbox.get(repr(i))
!         if scanparser.match(line) >= 0:
!             num = string.atoi(scanparser.group(1))
!             if num >= near:
!                 break
!     else:
!         i = 'end'
!     scanbox.select_from(i)
!     scanbox.yview(itop)
  
  def setfolders():
!     folderbox.delete(0, 'end')
!     for fn in mh.listallfolders():
!         folderbox.insert('end', fn)
  
  def rescan():
!     global viewer
!     if viewer:
!         viewer.destroy()
!         viewer = None
!     scanbox.delete(0, 'end')
!     for line in scanfolder(folder, seq):
!         scanbox.insert('end', line)
  
  def scanfolder(folder = 'inbox', sequence = 'all'):
!     return map(
!             lambda line: line[:-1],
!             os.popen('scan +%s %s' % (folder, sequence), 'r').readlines())
  
  main()

Index: newmenubardemo.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/newmenubardemo.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** newmenubardemo.py	6 Oct 1998 19:37:20 -0000	1.2
--- newmenubardemo.py	18 Jul 2004 06:09:09 -0000	1.3
***************
*** 8,28 ****
  
      def __init__(self, master):
! 	self.master = master
  
! 	self.menubar = Menu(self.master)
  
!  	self.filemenu = Menu(self.menubar)
! 	
!  	self.filemenu.add_command(label="New")
!  	self.filemenu.add_command(label="Open...")
!  	self.filemenu.add_command(label="Close")
!  	self.filemenu.add_separator()
!  	self.filemenu.add_command(label="Quit", command=self.master.quit)
  
! 	self.editmenu = Menu(self.menubar)
  
!  	self.editmenu.add_command(label="Cut")
!  	self.editmenu.add_command(label="Copy")
!  	self.editmenu.add_command(label="Paste")
  
          self.helpmenu = Menu(self.menubar, name='help')
--- 8,28 ----
  
      def __init__(self, master):
!         self.master = master
  
!         self.menubar = Menu(self.master)
  
!         self.filemenu = Menu(self.menubar)
  
!         self.filemenu.add_command(label="New")
!         self.filemenu.add_command(label="Open...")
!         self.filemenu.add_command(label="Close")
!         self.filemenu.add_separator()
!         self.filemenu.add_command(label="Quit", command=self.master.quit)
  
!         self.editmenu = Menu(self.menubar)
! 
!         self.editmenu.add_command(label="Cut")
!         self.editmenu.add_command(label="Copy")
!         self.editmenu.add_command(label="Paste")
  
          self.helpmenu = Menu(self.menubar, name='help')
***************
*** 30,40 ****
          self.helpmenu.add_command(label="About...")
  
! 	self.menubar.add_cascade(label="File", menu=self.filemenu)
! 	self.menubar.add_cascade(label="Edit", menu=self.editmenu)
! 	self.menubar.add_cascade(label="Help", menu=self.helpmenu)
  
! 	self.top = Toplevel(menu=self.menubar)
  
! 	# Rest of app goes here...
  
  def main():
--- 30,40 ----
          self.helpmenu.add_command(label="About...")
  
!         self.menubar.add_cascade(label="File", menu=self.filemenu)
!         self.menubar.add_cascade(label="Edit", menu=self.editmenu)
!         self.menubar.add_cascade(label="Help", menu=self.helpmenu)
  
!         self.top = Toplevel(menu=self.menubar)
  
!         # Rest of app goes here...
  
  def main():

Index: paint.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/paint.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** paint.py	26 Jan 1998 16:47:30 -0000	1.1
--- paint.py	18 Jul 2004 06:09:09 -0000	1.2
***************
*** 13,22 ****
    All this does is put up a canvas and draw a smooth black line
  whenever you have the mouse button down, but hopefully it will
! be enough to start with.. It would be easy enough to add some 
  options like other shapes or colors...
  
! 						yours,
! 						dave mitchell
! 						davem at magnet.com
  """
  
--- 13,22 ----
    All this does is put up a canvas and draw a smooth black line
  whenever you have the mouse button down, but hopefully it will
! be enough to start with.. It would be easy enough to add some
  options like other shapes or colors...
  
!                                                 yours,
!                                                 dave mitchell
!                                                 davem at magnet.com
  """
  
***************
*** 29,60 ****
  
  def main():
!   root = Tk()
!   drawing_area = Canvas(root)
!   drawing_area.pack()
!   drawing_area.bind("<Motion>", motion)
!   drawing_area.bind("<ButtonPress-1>", b1down)
!   drawing_area.bind("<ButtonRelease-1>", b1up)
!   root.mainloop()
  
  def b1down(event):
!   global b1
!   b1 = "down"		# you only want to draw when the button is down
! 			# because "Motion" events happen -all the time-
  
  def b1up(event):
!   global b1, xold, yold
!   b1 = "up"
!   xold = None		# reset the line when you let go of the button
!   yold = None
  
  def motion(event):
!   if b1 == "down":
!     global xold, yold
!     if xold != None and yold != None:
!       event.widget.create_line(xold,yold,event.x,event.y,smooth=TRUE)
! 			# here's where you draw it. smooth. neat.
!     xold = event.x
!     yold = event.y
  
  if __name__ == "__main__":
!   main()
--- 29,60 ----
  
  def main():
!     root = Tk()
!     drawing_area = Canvas(root)
!     drawing_area.pack()
!     drawing_area.bind("<Motion>", motion)
!     drawing_area.bind("<ButtonPress-1>", b1down)
!     drawing_area.bind("<ButtonRelease-1>", b1up)
!     root.mainloop()
  
  def b1down(event):
!     global b1
!     b1 = "down"           # you only want to draw when the button is down
!                           # because "Motion" events happen -all the time-
  
  def b1up(event):
!     global b1, xold, yold
!     b1 = "up"
!     xold = None           # reset the line when you let go of the button
!     yold = None
  
  def motion(event):
!     if b1 == "down":
!         global xold, yold
!         if xold != None and yold != None:
!             event.widget.create_line(xold,yold,event.x,event.y,smooth=TRUE)
!                           # here's where you draw it. smooth. neat.
!         xold = event.x
!         yold = event.y
  
  if __name__ == "__main__":
!     main()

Index: rmt.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/rmt.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rmt.py	27 Nov 1996 19:51:30 -0000	1.6
--- rmt.py	18 Jul 2004 06:09:09 -0000	1.7
***************
*** 29,33 ****
  t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1)
  t.pack(side=LEFT, fill=BOTH, expand=1)
! t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*') 
  s['command'] = t.yview
  
--- 29,33 ----
  t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1)
  t.pack(side=LEFT, fill=BOTH, expand=1)
! t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*')
  s['command'] = t.yview
  
***************
*** 43,47 ****
  file_m_apps = Menu(file_m, tearoff=0)
  file_m.add_cascade(label='Select Application', underline=0,
! 		   menu=file_m_apps)
  file_m.add_command(label='Quit', underline=0, command=sys.exit)
  
--- 43,47 ----
  file_m_apps = Menu(file_m, tearoff=0)
  file_m.add_cascade(label='Select Application', underline=0,
!                    menu=file_m_apps)
  file_m.add_command(label='Quit', underline=0, command=sys.exit)
  
***************
*** 52,86 ****
  
  def single1(e):
! 	x = e.x
! 	y = e.y
! 	t.setvar('tk_priv(selectMode)', 'char')
! 	t.mark_set('anchor', At(x, y))
! 	# Should focus W
  t.bind('<1>', single1)
  
  def double1(e):
! 	x = e.x
! 	y = e.y
! 	t.setvar('tk_priv(selectMode)', 'word')
! 	t.tk_textSelectTo(At(x, y))
  t.bind('<Double-1>', double1)
  
  def triple1(e):
! 	x = e.x
! 	y = e.y
! 	t.setvar('tk_priv(selectMode)', 'line')
! 	t.tk_textSelectTo(At(x, y))
  t.bind('<Triple-1>', triple1)
  
  def returnkey(e):
! 	t.insert(AtInsert(), '\n')
! 	invoke()
  t.bind('<Return>', returnkey)
  
  def controlv(e):
! 	t.insert(AtInsert(), t.selection_get())
! 	t.yview_pickplace(AtInsert())
! 	if t.index(AtInsert())[-2:] == '.0':
! 		invoke()
  t.bind('<Control-v>', controlv)
  
--- 52,86 ----
  
  def single1(e):
!     x = e.x
!     y = e.y
!     t.setvar('tk_priv(selectMode)', 'char')
!     t.mark_set('anchor', At(x, y))
!     # Should focus W
  t.bind('<1>', single1)
  
  def double1(e):
!     x = e.x
!     y = e.y
!     t.setvar('tk_priv(selectMode)', 'word')
!     t.tk_textSelectTo(At(x, y))
  t.bind('<Double-1>', double1)
  
  def triple1(e):
!     x = e.x
!     y = e.y
!     t.setvar('tk_priv(selectMode)', 'line')
!     t.tk_textSelectTo(At(x, y))
  t.bind('<Triple-1>', triple1)
  
  def returnkey(e):
!     t.insert(AtInsert(), '\n')
!     invoke()
  t.bind('<Return>', returnkey)
  
  def controlv(e):
!     t.insert(AtInsert(), t.selection_get())
!     t.yview_pickplace(AtInsert())
!     if t.index(AtInsert())[-2:] == '.0':
!         invoke()
  t.bind('<Control-v>', controlv)
  
***************
*** 89,95 ****
  
  def backspace(e):
! 	if t.index('promptEnd') != t.index('insert - 1 char'):
! 		t.delete('insert - 1 char', AtInsert())
! 		t.yview_pickplace(AtInsert())
  t.bind('<BackSpace>', backspace)
  t.bind('<Control-h>', backspace)
--- 89,95 ----
  
  def backspace(e):
!     if t.index('promptEnd') != t.index('insert - 1 char'):
!         t.delete('insert - 1 char', AtInsert())
!         t.yview_pickplace(AtInsert())
  t.bind('<BackSpace>', backspace)
  t.bind('<Control-h>', backspace)
***************
*** 104,122 ****
  
  def invoke():
! 	cmd = t.get('promptEnd + 1 char', AtInsert())
! 	if t.getboolean(tk.call('info', 'complete', cmd)): # XXX
! 		if app == root.winfo_name():
! 			msg = tk.call('eval', cmd) # XXX
! 		else:
! 			msg = t.send(app, cmd)
! 		if msg:
! 			t.insert(AtInsert(), msg + '\n')
! 		prompt()
! 	t.yview_pickplace(AtInsert())
  
  def prompt():
! 	t.insert(AtInsert(), app + ': ')
! 	t.mark_set('promptEnd', 'insert - 1 char')
! 	t.tag_add('bold', 'insert linestart', 'promptEnd')
  
  # 6. Procedure to select a new application.  Also changes
--- 104,122 ----
  
  def invoke():
!     cmd = t.get('promptEnd + 1 char', AtInsert())
!     if t.getboolean(tk.call('info', 'complete', cmd)): # XXX
!         if app == root.winfo_name():
!             msg = tk.call('eval', cmd) # XXX
!         else:
!             msg = t.send(app, cmd)
!         if msg:
!             t.insert(AtInsert(), msg + '\n')
!         prompt()
!     t.yview_pickplace(AtInsert())
  
  def prompt():
!     t.insert(AtInsert(), app + ': ')
!     t.mark_set('promptEnd', 'insert - 1 char')
!     t.tag_add('bold', 'insert linestart', 'promptEnd')
  
  # 6. Procedure to select a new application.  Also changes
***************
*** 125,150 ****
  
  def newApp(appName):
! 	global app
! 	app = appName
! 	t.delete('promptEnd linestart', 'promptEnd')
! 	t.insert('promptEnd', appName + ':')
! 	t.tag_add('bold', 'promptEnd linestart', 'promptEnd')
  
  def fillAppsMenu():
! 	file_m_apps.add('command')
! 	file_m_apps.delete(0, 'last')
! 	names = root.winfo_interps()
! 	names = map(None, names) # convert tuple to list
! 	names.sort()
! 	for name in names:
! 		try:
! 			root.send(name, 'winfo name .')
! 		except TclError:
! 			# Inoperative window -- ignore it
! 			pass
! 		else:
! 			file_m_apps.add_command(
! 			    label=name,
! 			    command=lambda name=name: newApp(name))
  
  file_m_apps['postcommand'] = fillAppsMenu
--- 125,150 ----
  
  def newApp(appName):
!     global app
!     app = appName
!     t.delete('promptEnd linestart', 'promptEnd')
!     t.insert('promptEnd', appName + ':')
!     t.tag_add('bold', 'promptEnd linestart', 'promptEnd')
  
  def fillAppsMenu():
!     file_m_apps.add('command')
!     file_m_apps.delete(0, 'last')
!     names = root.winfo_interps()
!     names = map(None, names) # convert tuple to list
!     names.sort()
!     for name in names:
!         try:
!             root.send(name, 'winfo name .')
!         except TclError:
!             # Inoperative window -- ignore it
!             pass
!         else:
!             file_m_apps.add_command(
!                 label=name,
!                 command=lambda name=name: newApp(name))
  
  file_m_apps['postcommand'] = fillAppsMenu

Index: solitaire.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/solitaire.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** solitaire.py	12 Feb 2004 17:35:04 -0000	1.5
--- solitaire.py	18 Jul 2004 06:09:09 -0000	1.6
***************
*** 12,16 ****
  - Less fancy animation when you win.
  - The determination of which stack you drag to is more relaxed.
!   
  Apology:
  
--- 12,16 ----
  - Less fancy animation when you win.
  - The determination of which stack you drag to is more relaxed.
! 
  Apology:
  
***************
*** 36,40 ****
  class Group(Group):
      def bind(self, sequence=None, command=None):
! 	return self.canvas.tag_bind(self.id, sequence, command)
  
  
--- 36,40 ----
  class Group(Group):
      def bind(self, sequence=None, command=None):
!         return self.canvas.tag_bind(self.id, sequence, command)
  
  
***************
*** 136,140 ****
      Semi-public read-only instance variables (XXX should be made
      private):
!     
      group -- the Canvas.Group representing the card
      x, y -- the position of the card's top left corner
--- 136,140 ----
      Semi-public read-only instance variables (XXX should be made
      private):
! 
      group -- the Canvas.Group representing the card
      x, y -- the position of the card's top left corner
***************
*** 151,216 ****
  
      def __init__(self, suit, value, canvas):
! 	"""Card constructor.
  
! 	Arguments are the card's suit and value, and the canvas widget.
  
! 	The card is created at position (0, 0), with its face down
! 	(adding it to a stack will position it according to that
! 	stack's rules).
  
! 	"""
! 	self.suit = suit
! 	self.value = value
! 	self.color = COLOR[suit]
! 	self.face_shown = 0
  
! 	self.x = self.y = 0
! 	self.group = Group(canvas)
  
! 	text = "%s  %s" % (VALNAMES[value], suit)
! 	self.__text = CanvasText(canvas, CARDWIDTH/2, 0,
! 			       anchor=N, fill=self.color, text=text)
! 	self.group.addtag_withtag(self.__text)
  
! 	self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT,
! 			      outline='black', fill='white')
! 	self.group.addtag_withtag(self.__rect)
  
! 	self.__back = Rectangle(canvas, MARGIN, MARGIN,
! 			      CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN,
! 			      outline='black', fill='blue')
! 	self.group.addtag_withtag(self.__back)
  
      def __repr__(self):
! 	"""Return a string for debug print statements."""
! 	return "Card(%r, %r)" % (self.suit, self.value)
  
      def moveto(self, x, y):
! 	"""Move the card to absolute position (x, y)."""
! 	self.moveby(x - self.x, y - self.y)
  
      def moveby(self, dx, dy):
! 	"""Move the card by (dx, dy)."""
! 	self.x = self.x + dx
! 	self.y = self.y + dy
! 	self.group.move(dx, dy)
  
      def tkraise(self):
! 	"""Raise the card above all other objects in its canvas."""
! 	self.group.tkraise()
  
      def showface(self):
! 	"""Turn the card's face up."""
! 	self.tkraise()
! 	self.__rect.tkraise()
! 	self.__text.tkraise()
! 	self.face_shown = 1
  
      def showback(self):
! 	"""Turn the card's face down."""
! 	self.tkraise()
! 	self.__rect.tkraise()
! 	self.__back.tkraise()
! 	self.face_shown = 0
  
  
--- 151,216 ----
  
      def __init__(self, suit, value, canvas):
!         """Card constructor.
  
!         Arguments are the card's suit and value, and the canvas widget.
  
!         The card is created at position (0, 0), with its face down
!         (adding it to a stack will position it according to that
!         stack's rules).
  
!         """
!         self.suit = suit
!         self.value = value
!         self.color = COLOR[suit]
!         self.face_shown = 0
  
!         self.x = self.y = 0
!         self.group = Group(canvas)
  
!         text = "%s  %s" % (VALNAMES[value], suit)
!         self.__text = CanvasText(canvas, CARDWIDTH/2, 0,
!                                anchor=N, fill=self.color, text=text)
!         self.group.addtag_withtag(self.__text)
  
!         self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT,
!                               outline='black', fill='white')
!         self.group.addtag_withtag(self.__rect)
  
!         self.__back = Rectangle(canvas, MARGIN, MARGIN,
!                               CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN,
!                               outline='black', fill='blue')
!         self.group.addtag_withtag(self.__back)
  
      def __repr__(self):
!         """Return a string for debug print statements."""
!         return "Card(%r, %r)" % (self.suit, self.value)
  
      def moveto(self, x, y):
!         """Move the card to absolute position (x, y)."""
!         self.moveby(x - self.x, y - self.y)
  
      def moveby(self, dx, dy):
!         """Move the card by (dx, dy)."""
!         self.x = self.x + dx
!         self.y = self.y + dy
!         self.group.move(dx, dy)
  
      def tkraise(self):
!         """Raise the card above all other objects in its canvas."""
!         self.group.tkraise()
  
      def showface(self):
!         """Turn the card's face up."""
!         self.tkraise()
!         self.__rect.tkraise()
!         self.__text.tkraise()
!         self.face_shown = 1
  
      def showback(self):
!         """Turn the card's face down."""
!         self.tkraise()
!         self.__rect.tkraise()
!         self.__back.tkraise()
!         self.face_shown = 0
  
  
***************
*** 241,245 ****
          The default user (single) click handler shows the top card
          face up.  The default user double click handler calls the user
! 	single click handler.
  
      usermovehandler(cards) -- called to complete a subpile move
--- 241,245 ----
          The default user (single) click handler shows the top card
          face up.  The default user double click handler calls the user
!         single click handler.
  
      usermovehandler(cards) -- called to complete a subpile move
***************
*** 256,260 ****
          its face up on a (single or double) click, and also support
          moving a subpile around.
!     
      startmoving(event) -- begin a move operation
      finishmoving() -- finish a move operation
--- 256,260 ----
          its face up on a (single or double) click, and also support
          moving a subpile around.
! 
      startmoving(event) -- begin a move operation
      finishmoving() -- finish a move operation
***************
*** 263,348 ****
  
      def __init__(self, x, y, game=None):
! 	"""Stack constructor.
  
! 	Arguments are the stack's nominal x and y position (the top
! 	left corner of the first card placed in the stack), and the
! 	game object (which is used to get the canvas; subclasses use
! 	the game object to find other stacks).
  
! 	"""
! 	self.x = x
! 	self.y = y
! 	self.game = game
! 	self.cards = []
! 	self.group = Group(self.game.canvas)
! 	self.group.bind('<1>', self.clickhandler)
!  	self.group.bind('<Double-1>', self.doubleclickhandler)
! 	self.group.bind('<B1-Motion>', self.motionhandler)
! 	self.group.bind('<ButtonRelease-1>', self.releasehandler)
! 	self.makebottom()
  
      def makebottom(self):
! 	pass
  
      def __repr__(self):
! 	"""Return a string for debug print statements."""
! 	return "%s(%d, %d)" % (self.__class__.__name__, self.x, self.y)
  
      # Public methods
  
      def add(self, card):
! 	self.cards.append(card)
! 	card.tkraise()
! 	self.position(card)
! 	self.group.addtag_withtag(card.group)
  
      def delete(self, card):
! 	self.cards.remove(card)
! 	card.group.dtag(self.group)
  
      def showtop(self):
! 	if self.cards:
! 	    self.cards[-1].showface()
  
      def deal(self):
! 	if not self.cards:
! 	    return None
! 	card = self.cards[-1]
! 	self.delete(card)
! 	return card
  
      # Subclass overridable methods
  
      def position(self, card):
! 	card.moveto(self.x, self.y)
  
      def userclickhandler(self):
! 	self.showtop()
  
      def userdoubleclickhandler(self):
! 	self.userclickhandler()
  
      def usermovehandler(self, cards):
! 	for card in cards:
! 	    self.position(card)
  
      # Event handlers
  
      def clickhandler(self, event):
! 	self.finishmoving()		# In case we lost an event
! 	self.userclickhandler()
! 	self.startmoving(event)
  
      def motionhandler(self, event):
! 	self.keepmoving(event)
  
      def releasehandler(self, event):
! 	self.keepmoving(event)
! 	self.finishmoving()
  
      def doubleclickhandler(self, event):
! 	self.finishmoving()		# In case we lost an event
! 	self.userdoubleclickhandler()
! 	self.startmoving(event)
  
      # Move internals
--- 263,348 ----
  
      def __init__(self, x, y, game=None):
!         """Stack constructor.
  
!         Arguments are the stack's nominal x and y position (the top
!         left corner of the first card placed in the stack), and the
!         game object (which is used to get the canvas; subclasses use
!         the game object to find other stacks).
  
!         """
!         self.x = x
!         self.y = y
!         self.game = game
!         self.cards = []
!         self.group = Group(self.game.canvas)
!         self.group.bind('<1>', self.clickhandler)
!         self.group.bind('<Double-1>', self.doubleclickhandler)
!         self.group.bind('<B1-Motion>', self.motionhandler)
!         self.group.bind('<ButtonRelease-1>', self.releasehandler)
!         self.makebottom()
  
      def makebottom(self):
!         pass
  
      def __repr__(self):
!         """Return a string for debug print statements."""
!         return "%s(%d, %d)" % (self.__class__.__name__, self.x, self.y)
  
      # Public methods
  
      def add(self, card):
!         self.cards.append(card)
!         card.tkraise()
!         self.position(card)
!         self.group.addtag_withtag(card.group)
  
      def delete(self, card):
!         self.cards.remove(card)
!         card.group.dtag(self.group)
  
      def showtop(self):
!         if self.cards:
!             self.cards[-1].showface()
  
      def deal(self):
!         if not self.cards:
!             return None
!         card = self.cards[-1]
!         self.delete(card)
!         return card
  
      # Subclass overridable methods
  
      def position(self, card):
!         card.moveto(self.x, self.y)
  
      def userclickhandler(self):
!         self.showtop()
  
      def userdoubleclickhandler(self):
!         self.userclickhandler()
  
      def usermovehandler(self, cards):
!         for card in cards:
!             self.position(card)
  
      # Event handlers
  
      def clickhandler(self, event):
!         self.finishmoving()             # In case we lost an event
!         self.userclickhandler()
!         self.startmoving(event)
  
      def motionhandler(self, event):
!         self.keepmoving(event)
  
      def releasehandler(self, event):
!         self.keepmoving(event)
!         self.finishmoving()
  
      def doubleclickhandler(self, event):
!         self.finishmoving()             # In case we lost an event
!         self.userdoubleclickhandler()
!         self.startmoving(event)
  
      # Move internals
***************
*** 351,386 ****
  
      def startmoving(self, event):
! 	self.moving = None
! 	tags = self.game.canvas.gettags('current')
! 	for i in range(len(self.cards)):
! 	    card = self.cards[i]
! 	    if card.group.tag in tags:
! 		break
! 	else:
! 	    return
! 	if not card.face_shown:
! 	    return
! 	self.moving = self.cards[i:]
! 	self.lastx = event.x
! 	self.lasty = event.y
! 	for card in self.moving:
! 	    card.tkraise()
  
      def keepmoving(self, event):
! 	if not self.moving:
! 	    return
! 	dx = event.x - self.lastx
! 	dy = event.y - self.lasty
! 	self.lastx = event.x
! 	self.lasty = event.y
! 	if dx or dy:
! 	    for card in self.moving:
! 		card.moveby(dx, dy)
  
      def finishmoving(self):
! 	cards = self.moving
! 	self.moving = None
! 	if cards:
! 	    self.usermovehandler(cards)
  
  
--- 351,386 ----
  
      def startmoving(self, event):
!         self.moving = None
!         tags = self.game.canvas.gettags('current')
!         for i in range(len(self.cards)):
!             card = self.cards[i]
!             if card.group.tag in tags:
!                 break
!         else:
!             return
!         if not card.face_shown:
!             return
!         self.moving = self.cards[i:]
!         self.lastx = event.x
!         self.lasty = event.y
!         for card in self.moving:
!             card.tkraise()
  
      def keepmoving(self, event):
!         if not self.moving:
!             return
!         dx = event.x - self.lastx
!         dy = event.y - self.lasty
!         self.lastx = event.x
!         self.lasty = event.y
!         if dx or dy:
!             for card in self.moving:
!                 card.moveby(dx, dy)
  
      def finishmoving(self):
!         cards = self.moving
!         self.moving = None
!         if cards:
!             self.usermovehandler(cards)
  
  
***************
*** 401,435 ****
  
      def makebottom(self):
! 	bottom = Rectangle(self.game.canvas,
! 			   self.x, self.y,
! 			   self.x+CARDWIDTH, self.y+CARDHEIGHT,
! 			   outline='black', fill=BACKGROUND)
!  	self.group.addtag_withtag(bottom)
  
      def fill(self):
! 	for suit in ALLSUITS:
! 	    for value in ALLVALUES:
! 		self.add(Card(suit, value, self.game.canvas))
  
      def shuffle(self):
! 	n = len(self.cards)
! 	newcards = []
! 	for i in randperm(n):
! 	    newcards.append(self.cards[i])
! 	self.cards = newcards
  
      def userclickhandler(self):
! 	opendeck = self.game.opendeck
! 	card = self.deal()
! 	if not card:
! 	    while 1:
! 		card = opendeck.deal()
! 		if not card:
! 		    break
! 		self.add(card)
! 		card.showback()
! 	else:
! 	    self.game.opendeck.add(card)
! 	    card.showface()
  
  
--- 401,435 ----
  
      def makebottom(self):
!         bottom = Rectangle(self.game.canvas,
!                            self.x, self.y,
!                            self.x+CARDWIDTH, self.y+CARDHEIGHT,
!                            outline='black', fill=BACKGROUND)
!         self.group.addtag_withtag(bottom)
  
      def fill(self):
!         for suit in ALLSUITS:
!             for value in ALLVALUES:
!                 self.add(Card(suit, value, self.game.canvas))
  
      def shuffle(self):
!         n = len(self.cards)
!         newcards = []
!         for i in randperm(n):
!             newcards.append(self.cards[i])
!         self.cards = newcards
  
      def userclickhandler(self):
!         opendeck = self.game.opendeck
!         card = self.deal()
!         if not card:
!             while 1:
!                 card = opendeck.deal()
!                 if not card:
!                     break
!                 self.add(card)
!                 card.showback()
!         else:
!             self.game.opendeck.add(card)
!             card.showface()
  
  
***************
*** 439,445 ****
      x = []
      while r:
! 	i = random.choice(r)
! 	x.append(i)
! 	r.remove(i)
      return x
  
--- 439,445 ----
      x = []
      while r:
!         i = random.choice(r)
!         x.append(i)
!         r.remove(i)
      return x
  
***************
*** 448,477 ****
  
      def acceptable(self, cards):
! 	return 0
  
      def usermovehandler(self, cards):
! 	card = cards[0]
! 	stack = self.game.closeststack(card)
! 	if not stack or stack is self or not stack.acceptable(cards):
! 	    Stack.usermovehandler(self, cards)
! 	else:
! 	    for card in cards:
! 		self.delete(card)
! 		stack.add(card)
! 	    self.game.wincheck()
  
      def userdoubleclickhandler(self):
! 	if not self.cards:
! 	    return
! 	card = self.cards[-1]
! 	if not card.face_shown:
! 	    self.userclickhandler()
! 	    return
! 	for s in self.game.suits:
! 	    if s.acceptable([card]):
! 		self.delete(card)
! 		s.add(card)
! 		self.game.wincheck()
! 		break
  
  
--- 448,477 ----
  
      def acceptable(self, cards):
!         return 0
  
      def usermovehandler(self, cards):
!         card = cards[0]
!         stack = self.game.closeststack(card)
!         if not stack or stack is self or not stack.acceptable(cards):
!             Stack.usermovehandler(self, cards)
!         else:
!             for card in cards:
!                 self.delete(card)
!                 stack.add(card)
!             self.game.wincheck()
  
      def userdoubleclickhandler(self):
!         if not self.cards:
!             return
!         card = self.cards[-1]
!         if not card.face_shown:
!             self.userclickhandler()
!             return
!         for s in self.game.suits:
!             if s.acceptable([card]):
!                 self.delete(card)
!                 s.add(card)
!                 self.game.wincheck()
!                 break
  
  
***************
*** 479,501 ****
  
      def makebottom(self):
! 	bottom = Rectangle(self.game.canvas,
! 			   self.x, self.y,
! 			   self.x+CARDWIDTH, self.y+CARDHEIGHT,
! 			   outline='black', fill='')
  
      def userclickhandler(self):
! 	pass
  
      def userdoubleclickhandler(self):
! 	pass
  
      def acceptable(self, cards):
! 	if len(cards) != 1:
! 	    return 0
! 	card = cards[0]
! 	if not self.cards:
! 	    return card.value == ACE
! 	topcard = self.cards[-1]
! 	return card.suit == topcard.suit and card.value == topcard.value + 1
  
  
--- 479,501 ----
  
      def makebottom(self):
!         bottom = Rectangle(self.game.canvas,
!                            self.x, self.y,
!                            self.x+CARDWIDTH, self.y+CARDHEIGHT,
!                            outline='black', fill='')
  
      def userclickhandler(self):
!         pass
  
      def userdoubleclickhandler(self):
!         pass
  
      def acceptable(self, cards):
!         if len(cards) != 1:
!             return 0
!         card = cards[0]
!         if not self.cards:
!             return card.value == ACE
!         topcard = self.cards[-1]
!         return card.suit == topcard.suit and card.value == topcard.value + 1
  
  
***************
*** 503,524 ****
  
      def acceptable(self, cards):
! 	card = cards[0]
! 	if not self.cards:
! 	    return card.value == KING
! 	topcard = self.cards[-1]
! 	if not topcard.face_shown:
! 	    return 0
! 	return card.color != topcard.color and card.value == topcard.value - 1
  
      def position(self, card):
! 	y = self.y
! 	for c in self.cards:
! 	    if c == card:
! 		break
! 	    if c.face_shown:
! 		y = y + 2*MARGIN
! 	    else:
! 		y = y + OFFSET
! 	card.moveto(self.x, y)
  
  
--- 503,524 ----
  
      def acceptable(self, cards):
!         card = cards[0]
!         if not self.cards:
!             return card.value == KING
!         topcard = self.cards[-1]
!         if not topcard.face_shown:
!             return 0
!         return card.color != topcard.color and card.value == topcard.value - 1
  
      def position(self, card):
!         y = self.y
!         for c in self.cards:
!             if c == card:
!                 break
!             if c.face_shown:
!                 y = y + 2*MARGIN
!             else:
!                 y = y + OFFSET
!         card.moveto(self.x, y)
  
  
***************
*** 526,627 ****
  
      def __init__(self, master):
! 	self.master = master
  
! 	self.canvas = Canvas(self.master,
! 			     background=BACKGROUND,
! 			     highlightthickness=0,
! 			     width=NROWS*XSPACING,
! 			     height=3*YSPACING + 20 + MARGIN)
! 	self.canvas.pack(fill=BOTH, expand=TRUE)
  
! 	self.dealbutton = Button(self.canvas,
! 				 text="Deal",
! 				 highlightthickness=0,
! 				 background=BACKGROUND,
! 				 activebackground="green",
! 				 command=self.deal)
! 	Window(self.canvas, MARGIN, 3*YSPACING + 20,
! 	       window=self.dealbutton, anchor=SW)
  
! 	x = MARGIN
! 	y = MARGIN
  
! 	self.deck = Deck(x, y, self)
  
! 	x = x + XSPACING
! 	self.opendeck = OpenStack(x, y, self)
! 	
! 	x = x + XSPACING
! 	self.suits = []
! 	for i in range(NSUITS):
! 	    x = x + XSPACING
! 	    self.suits.append(SuitStack(x, y, self))
  
! 	x = MARGIN
! 	y = y + YSPACING
  
! 	self.rows = []
! 	for i in range(NROWS):
! 	    self.rows.append(RowStack(x, y, self))
! 	    x = x + XSPACING
  
! 	self.openstacks = [self.opendeck] + self.suits + self.rows
! 	
! 	self.deck.fill()
! 	self.deal()
  
      def wincheck(self):
! 	for s in self.suits:
! 	    if len(s.cards) != NVALUES:
! 		return
! 	self.win()
! 	self.deal()
  
      def win(self):
! 	"""Stupid animation when you win."""
! 	cards = []
! 	for s in self.openstacks:
! 	    cards = cards + s.cards
! 	while cards:
! 	    card = random.choice(cards)
! 	    cards.remove(card)
! 	    self.animatedmoveto(card, self.deck)
  
      def animatedmoveto(self, card, dest):
! 	for i in range(10, 0, -1):
! 	    dx, dy = (dest.x-card.x)/i, (dest.y-card.y)/i
! 	    card.moveby(dx, dy)
! 	    self.master.update_idletasks()
  
      def closeststack(self, card):
! 	closest = None
! 	cdist = 999999999
! 	# Since we only compare distances,
! 	# we don't bother to take the square root.
! 	for stack in self.openstacks:
! 	    dist = (stack.x - card.x)**2 + (stack.y - card.y)**2
! 	    if dist < cdist:
! 		closest = stack
! 		cdist = dist
! 	return closest
  
      def deal(self):
! 	self.reset()
! 	self.deck.shuffle()
! 	for i in range(NROWS):
! 	    for r in self.rows[i:]:
! 		card = self.deck.deal()
! 		r.add(card)
! 	for r in self.rows:
! 	    r.showtop()
  
      def reset(self):
! 	for stack in self.openstacks:
! 	    while 1:
! 		card = stack.deal()
! 		if not card:
! 		    break
! 		self.deck.add(card)
! 		card.showback()
  
  
--- 526,627 ----
  
      def __init__(self, master):
!         self.master = master
  
!         self.canvas = Canvas(self.master,
!                              background=BACKGROUND,
!                              highlightthickness=0,
!                              width=NROWS*XSPACING,
!                              height=3*YSPACING + 20 + MARGIN)
!         self.canvas.pack(fill=BOTH, expand=TRUE)
  
!         self.dealbutton = Button(self.canvas,
!                                  text="Deal",
!                                  highlightthickness=0,
!                                  background=BACKGROUND,
!                                  activebackground="green",
!                                  command=self.deal)
!         Window(self.canvas, MARGIN, 3*YSPACING + 20,
!                window=self.dealbutton, anchor=SW)
  
!         x = MARGIN
!         y = MARGIN
  
!         self.deck = Deck(x, y, self)
  
!         x = x + XSPACING
!         self.opendeck = OpenStack(x, y, self)
  
!         x = x + XSPACING
!         self.suits = []
!         for i in range(NSUITS):
!             x = x + XSPACING
!             self.suits.append(SuitStack(x, y, self))
  
!         x = MARGIN
!         y = y + YSPACING
  
!         self.rows = []
!         for i in range(NROWS):
!             self.rows.append(RowStack(x, y, self))
!             x = x + XSPACING
! 
!         self.openstacks = [self.opendeck] + self.suits + self.rows
! 
!         self.deck.fill()
!         self.deal()
  
      def wincheck(self):
!         for s in self.suits:
!             if len(s.cards) != NVALUES:
!                 return
!         self.win()
!         self.deal()
  
      def win(self):
!         """Stupid animation when you win."""
!         cards = []
!         for s in self.openstacks:
!             cards = cards + s.cards
!         while cards:
!             card = random.choice(cards)
!             cards.remove(card)
!             self.animatedmoveto(card, self.deck)
  
      def animatedmoveto(self, card, dest):
!         for i in range(10, 0, -1):
!             dx, dy = (dest.x-card.x)/i, (dest.y-card.y)/i
!             card.moveby(dx, dy)
!             self.master.update_idletasks()
  
      def closeststack(self, card):
!         closest = None
!         cdist = 999999999
!         # Since we only compare distances,
!         # we don't bother to take the square root.
!         for stack in self.openstacks:
!             dist = (stack.x - card.x)**2 + (stack.y - card.y)**2
!             if dist < cdist:
!                 closest = stack
!                 cdist = dist
!         return closest
  
      def deal(self):
!         self.reset()
!         self.deck.shuffle()
!         for i in range(NROWS):
!             for r in self.rows[i:]:
!                 card = self.deck.deal()
!                 r.add(card)
!         for r in self.rows:
!             r.showtop()
  
      def reset(self):
!         for stack in self.openstacks:
!             while 1:
!                 card = stack.deal()
!                 if not card:
!                     break
!                 self.deck.add(card)
!                 card.showback()
  
  

Index: sortvisu.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/sortvisu.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** sortvisu.py	3 Apr 1997 00:04:51 -0000	1.1
--- sortvisu.py	18 Jul 2004 06:09:09 -0000	1.2
***************
*** 33,73 ****
  
      def __init__(self, master, data=None):
! 	self.master = master
! 	self.frame = Frame(self.master)
! 	self.frame.pack(fill=X)
! 	self.label = Label(self.frame)
! 	self.label.pack()
! 	self.canvas = Canvas(self.frame)
! 	self.canvas.pack()
! 	self.report = Label(self.frame)
[...1120 lines suppressed...]
      def c_cancel(self):
!         if not self.busy:
!             self.master.bell()
!             return
!         self.array.cancel()
  
      def c_step(self):
!         if not self.busy:
!             self.master.bell()
!             return
!         self.v_speed.set("single-step")
!         self.array.setspeed("single-step")
!         self.array.step()
  
      def c_quit(self):
!         if self.busy:
!             self.array.cancel()
!         self.master.after_idle(self.master.quit)
  
  

Index: ss1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/ss1.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ss1.py	2 Nov 2002 22:18:46 -0000	1.4
--- ss1.py	18 Jul 2004 06:09:09 -0000	1.5
***************
*** 316,320 ****
  
      Subclasses may but needn't provide the following APIs:
!     
      cell.reset() -- prepare for recalculation
      cell.recalc(rexec) -> value -- recalculate formula
--- 316,320 ----
  
      Subclasses may but needn't provide the following APIs:
! 
      cell.reset() -- prepare for recalculation
      cell.recalc(rexec) -> value -- recalculate formula

Index: svkill.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/svkill.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** svkill.py	27 Nov 1996 19:51:32 -0000	1.6
--- svkill.py	18 Jul 2004 06:09:09 -0000	1.7
***************
*** 6,10 ****
  
  if TkVersion < 4.0:
! 	raise ImportError, "This version of svkill requires Tk 4.0 or later"
  
  from string import splitfields
--- 6,10 ----
  
  if TkVersion < 4.0:
!     raise ImportError, "This version of svkill requires Tk 4.0 or later"
  
  from string import splitfields
***************
*** 16,128 ****
  
  class BarButton(Menubutton):
! 	def __init__(self, master=None, **cnf):
! 		apply(Menubutton.__init__, (self, master), cnf)
! 		self.pack(side=LEFT)
! 		self.menu = Menu(self, name='menu')
! 		self['menu'] = self.menu		
  
  class Kill(Frame):
! 	# List of (name, option, pid_column)
! 	view_list = [
! 		('Default', ''),
! 		('Every (-e)', '-e'),
! 		('Non process group leaders (-d)', '-d'),
! 		('Non leaders with tty (-a)', '-a'),
! 		('For this user (-u %s)' % user, '-u %s' % user),
! 		]
! 	format_list = [
! 		('Default', '', 0),
! 		('Long (-l)', '-l', 3),
! 		('Full (-f)', '-f', 1),
! 		('Full Long (-f -l)', '-l -f', 3),
! 		('Session and group ID (-j)', '-j', 0),
! 		('Scheduler properties (-c)', '-c', 0),
! 		]
! 	def kill(self, selected):
! 		c = self.format_list[self.format.get()][2]
! 		pid = split(selected)[c]
! 		os.system('kill -9 ' + pid)
! 		self.do_update()
! 	def do_update(self):
! 		format = self.format_list[self.format.get()][1]
! 		view = self.view_list[self.view.get()][1]
! 		s = commands.getoutput('ps %s %s' % (view, format))
! 		list = splitfields(s, '\n')
! 		self.header.set(list[0] + '          ')
! 		del list[0]
! 		self.frame.list.delete(0, AtEnd())
! 		for line in list:
! 			self.frame.list.insert(0, line)
! 	def do_motion(self, e):
! 		e.widget.select_clear('0', 'end')
! 		e.widget.select_set(e.widget.nearest(e.y))
! 	def do_leave(self, e):
! 		e.widget.select_clear('0', 'end')
! 	def do_1(self, e):
! 		self.kill(e.widget.get(e.widget.nearest(e.y)))
! 	def __init__(self, master=None, **cnf):
! 		apply(Frame.__init__, (self, master), cnf)
! 		self.pack(expand=1, fill=BOTH)
! 		self.bar = Frame(self, name='bar', relief=RAISED,
! 				 borderwidth=2)
! 		self.bar.pack(fill=X)
! 		self.bar.file = BarButton(self.bar, text='File')
! 		self.bar.file.menu.add_command(
! 			label='Quit', command=self.quit)
! 		self.bar.view = BarButton(self.bar, text='View')
! 		self.bar.format = BarButton(self.bar, text='Format')
! 		self.view = IntVar(self)
! 		self.view.set(0)
! 		self.format = IntVar(self)
! 		self.format.set(0)
! 		for num in range(len(self.view_list)):
! 			label, option = self.view_list[num]
! 			self.bar.view.menu.add_radiobutton(
! 				label=label,
! 				command=self.do_update,
! 				variable=self.view,
! 				value=num)
! 		for num in range(len(self.format_list)):
! 			label, option, col = self.format_list[num]
! 			self.bar.format.menu.add_radiobutton(
! 				label=label,
! 				command=self.do_update,
! 				variable=self.format,
! 				value=num)
! 		self.bar.tk_menuBar(self.bar.file,
! 				    self.bar.view,
! 				    self.bar.format)
! 		self.frame = Frame(self, relief=RAISED, borderwidth=2)
! 		self.frame.pack(expand=1, fill=BOTH)
! 		self.header = StringVar(self)
! 		self.frame.label = Label(
! 			self.frame, relief=FLAT, anchor=NW, borderwidth=0,
! 			font='*-Courier-Bold-R-Normal-*-120-*',
! 			textvariable=self.header)
! 		self.frame.label.pack(fill=Y, anchor=W)
! 		self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL)
! 		self.frame.list = Listbox(
! 			self.frame, 
! 			relief=SUNKEN,
! 			font='*-Courier-Medium-R-Normal-*-120-*',
! 			width=40, height=10,
! 			selectbackground='#eed5b7',
! 			selectborderwidth=0,
! 			selectmode=BROWSE,
! 			yscroll=self.frame.vscroll.set)
! 		self.frame.vscroll['command'] = self.frame.list.yview
! 		self.frame.vscroll.pack(side=RIGHT, fill=Y)
! 		self.frame.list.pack(expand=1, fill=BOTH)
! 		self.update = Button(self, text='Update',
! 				     command=self.do_update)
! 		self.update.pack(fill=X)
! 		self.frame.list.bind('<Motion>', self.do_motion)
! 		self.frame.list.bind('<Leave>', self.do_leave)
! 		self.frame.list.bind('<1>', self.do_1)
! 		self.do_update()
  
  if __name__ == '__main__':
! 	kill = Kill(None, borderwidth=5)
! 	kill.winfo_toplevel().title('Tkinter Process Killer (SYSV)')
! 	kill.winfo_toplevel().minsize(1, 1)
! 	kill.mainloop()
--- 16,128 ----
  
  class BarButton(Menubutton):
!     def __init__(self, master=None, **cnf):
!         apply(Menubutton.__init__, (self, master), cnf)
!         self.pack(side=LEFT)
!         self.menu = Menu(self, name='menu')
!         self['menu'] = self.menu
  
  class Kill(Frame):
!     # List of (name, option, pid_column)
!     view_list = [
!             ('Default', ''),
!             ('Every (-e)', '-e'),
!             ('Non process group leaders (-d)', '-d'),
!             ('Non leaders with tty (-a)', '-a'),
!             ('For this user (-u %s)' % user, '-u %s' % user),
!             ]
!     format_list = [
!             ('Default', '', 0),
!             ('Long (-l)', '-l', 3),
!             ('Full (-f)', '-f', 1),
!             ('Full Long (-f -l)', '-l -f', 3),
!             ('Session and group ID (-j)', '-j', 0),
!             ('Scheduler properties (-c)', '-c', 0),
!             ]
!     def kill(self, selected):
!         c = self.format_list[self.format.get()][2]
!         pid = split(selected)[c]
!         os.system('kill -9 ' + pid)
!         self.do_update()
!     def do_update(self):
!         format = self.format_list[self.format.get()][1]
!         view = self.view_list[self.view.get()][1]
!         s = commands.getoutput('ps %s %s' % (view, format))
!         list = splitfields(s, '\n')
!         self.header.set(list[0] + '          ')
!         del list[0]
!         self.frame.list.delete(0, AtEnd())
!         for line in list:
!             self.frame.list.insert(0, line)
!     def do_motion(self, e):
!         e.widget.select_clear('0', 'end')
!         e.widget.select_set(e.widget.nearest(e.y))
!     def do_leave(self, e):
!         e.widget.select_clear('0', 'end')
!     def do_1(self, e):
!         self.kill(e.widget.get(e.widget.nearest(e.y)))
!     def __init__(self, master=None, **cnf):
!         apply(Frame.__init__, (self, master), cnf)
!         self.pack(expand=1, fill=BOTH)
!         self.bar = Frame(self, name='bar', relief=RAISED,
!                          borderwidth=2)
!         self.bar.pack(fill=X)
!         self.bar.file = BarButton(self.bar, text='File')
!         self.bar.file.menu.add_command(
!                 label='Quit', command=self.quit)
!         self.bar.view = BarButton(self.bar, text='View')
!         self.bar.format = BarButton(self.bar, text='Format')
!         self.view = IntVar(self)
!         self.view.set(0)
!         self.format = IntVar(self)
!         self.format.set(0)
!         for num in range(len(self.view_list)):
!             label, option = self.view_list[num]
!             self.bar.view.menu.add_radiobutton(
!                     label=label,
!                     command=self.do_update,
!                     variable=self.view,
!                     value=num)
!         for num in range(len(self.format_list)):
!             label, option, col = self.format_list[num]
!             self.bar.format.menu.add_radiobutton(
!                     label=label,
!                     command=self.do_update,
!                     variable=self.format,
!                     value=num)
!         self.bar.tk_menuBar(self.bar.file,
!                             self.bar.view,
!                             self.bar.format)
!         self.frame = Frame(self, relief=RAISED, borderwidth=2)
!         self.frame.pack(expand=1, fill=BOTH)
!         self.header = StringVar(self)
!         self.frame.label = Label(
!                 self.frame, relief=FLAT, anchor=NW, borderwidth=0,
!                 font='*-Courier-Bold-R-Normal-*-120-*',
!                 textvariable=self.header)
!         self.frame.label.pack(fill=Y, anchor=W)
!         self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL)
!         self.frame.list = Listbox(
!                 self.frame,
!                 relief=SUNKEN,
!                 font='*-Courier-Medium-R-Normal-*-120-*',
!                 width=40, height=10,
!                 selectbackground='#eed5b7',
!                 selectborderwidth=0,
!                 selectmode=BROWSE,
!                 yscroll=self.frame.vscroll.set)
!         self.frame.vscroll['command'] = self.frame.list.yview
!         self.frame.vscroll.pack(side=RIGHT, fill=Y)
!         self.frame.list.pack(expand=1, fill=BOTH)
!         self.update = Button(self, text='Update',
!                              command=self.do_update)
!         self.update.pack(fill=X)
!         self.frame.list.bind('<Motion>', self.do_motion)
!         self.frame.list.bind('<Leave>', self.do_leave)
!         self.frame.list.bind('<1>', self.do_1)
!         self.do_update()
  
  if __name__ == '__main__':
!     kill = Kill(None, borderwidth=5)
!     kill.winfo_toplevel().title('Tkinter Process Killer (SYSV)')
!     kill.winfo_toplevel().minsize(1, 1)
!     kill.mainloop()

Index: tkman.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/tkman.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** tkman.py	15 Sep 1997 15:39:11 -0000	1.10
--- tkman.py	18 Jul 2004 06:09:09 -0000	1.11
***************
*** 16,44 ****
  for dir in MANNDIRLIST:
      if os.path.exists(dir):
! 	MANNDIR = dir
! 	foundmanndir = 1
  
  foundman3dir = 0
  for dir in MAN3DIRLIST:
      if os.path.exists(dir):
! 	MAN3DIR = dir
! 	foundman3dir =  1
  
  if not foundmanndir or not foundman3dir:
      sys.stderr.write('\n')
      if not foundmanndir:
! 	msg = """\
  Failed to find mann directory.
! Please add the correct entry to the MANNDIRLIST 
  at the top of %s script.""" % \
  sys.argv[0]
! 	sys.stderr.write("%s\n\n" % msg)
      if not foundman3dir:
! 	msg = """\
  Failed to find man3 directory.
! Please add the correct entry to the MAN3DIRLIST 
  at the top of %s script.""" % \
  sys.argv[0]
! 	sys.stderr.write("%s\n\n" % msg)
      sys.exit(1)
  
--- 16,44 ----
  for dir in MANNDIRLIST:
      if os.path.exists(dir):
!         MANNDIR = dir
!         foundmanndir = 1
  
  foundman3dir = 0
  for dir in MAN3DIRLIST:
      if os.path.exists(dir):
!         MAN3DIR = dir
!         foundman3dir =  1
  
  if not foundmanndir or not foundman3dir:
      sys.stderr.write('\n')
      if not foundmanndir:
!         msg = """\
  Failed to find mann directory.
! Please add the correct entry to the MANNDIRLIST
  at the top of %s script.""" % \
  sys.argv[0]
!         sys.stderr.write("%s\n\n" % msg)
      if not foundman3dir:
!         msg = """\
  Failed to find man3 directory.
! Please add the correct entry to the MAN3DIRLIST
  at the top of %s script.""" % \
  sys.argv[0]
!         sys.stderr.write("%s\n\n" % msg)
      sys.exit(1)
  
***************
*** 47,267 ****
  
  def listmanpages(mandir):
! 	files = os.listdir(mandir)
! 	names = []
! 	for file in files:
! 		if file[-2:-1] == '.' and  (file[-1] in 'ln123456789'):
! 			names.append(file[:-2])
! 	names.sort()
! 	return names
  
  class SelectionBox:
  
! 	def __init__(self, master=None):
! 		self.choices = []
  
! 		self.frame = Frame(master, name="frame")
! 		self.frame.pack(expand=1, fill=BOTH)
! 		self.master = self.frame.master
! 		self.subframe = Frame(self.frame, name="subframe")
! 		self.subframe.pack(expand=0, fill=BOTH)
! 		self.leftsubframe = Frame(self.subframe, name='leftsubframe')
! 		self.leftsubframe.pack(side=LEFT, expand=1, fill=BOTH)
! 		self.rightsubframe = Frame(self.subframe, name='rightsubframe')
! 		self.rightsubframe.pack(side=RIGHT, expand=1, fill=BOTH)
! 		self.chaptervar = StringVar(master)
! 		self.chapter = Menubutton(self.rightsubframe, name='chapter',
! 					  text='Directory', relief=RAISED,
! 					  borderwidth=2)
! 		self.chapter.pack(side=TOP)
! 		self.chaptermenu = Menu(self.chapter, name='chaptermenu')
! 		self.chaptermenu.add_radiobutton(label='C functions',
! 						 value=MAN3DIR,
! 						 variable=self.chaptervar,
! 						 command=self.newchapter)
! 		self.chaptermenu.add_radiobutton(label='Tcl/Tk functions',
! 						 value=MANNDIR,
! 						 variable=self.chaptervar,
! 						 command=self.newchapter)
! 		self.chapter['menu'] = self.chaptermenu
! 		self.listbox = Listbox(self.rightsubframe, name='listbox',
! 				       relief=SUNKEN, borderwidth=2,
! 				       width=20, height=5)
! 		self.listbox.pack(expand=1, fill=BOTH)
! 		self.l1 = Button(self.leftsubframe, name='l1',
! 				 text='Display manual page named:',
! 				 command=self.entry_cb)
! 		self.l1.pack(side=TOP)
! 		self.entry = Entry(self.leftsubframe, name='entry',
! 				    relief=SUNKEN, borderwidth=2,
! 				    width=20)
! 		self.entry.pack(expand=0, fill=X)
! 		self.l2frame = Frame(self.leftsubframe, name='l2frame')
! 		self.l2frame.pack(expand=0, fill=NONE)
! 		self.l2 = Button(self.l2frame, name='l2',
! 				 text='Search regexp:',
! 				 command=self.search_cb)
! 		self.l2.pack(side=LEFT)
! 		self.casevar = BooleanVar()
! 		self.casesense = Checkbutton(self.l2frame, name='casesense',
! 					     text='Case sensitive',
! 					     variable=self.casevar,
! 					     relief=FLAT)
! 		self.casesense.pack(side=LEFT)
! 		self.search = Entry(self.leftsubframe, name='search',
! 				    relief=SUNKEN, borderwidth=2,
! 				    width=20)
! 		self.search.pack(expand=0, fill=X)
! 		self.title = Label(self.leftsubframe, name='title',
! 				   text='(none)')
! 		self.title.pack(side=BOTTOM)
! 		self.text = ManPage(self.frame, name='text',
! 				    relief=SUNKEN, borderwidth=2,
! 				    wrap=NONE, width=72,
! 				    selectbackground='pink')
! 		self.text.pack(expand=1, fill=BOTH)
  
! 		self.entry.bind('<Return>', self.entry_cb)
! 		self.search.bind('<Return>', self.search_cb)
! 		self.listbox.bind('<Double-1>', self.listbox_cb)
  
! 		self.entry.bind('<Tab>', self.entry_tab)
! 		self.search.bind('<Tab>', self.search_tab)
! 		self.text.bind('<Tab>', self.text_tab)
  
! 		self.entry.focus_set()
  
! 		self.chaptervar.set(MANNDIR)
! 		self.newchapter()
  
! 	def newchapter(self):
! 		mandir = self.chaptervar.get()
! 		self.choices = []
! 		self.addlist(listmanpages(mandir))
  
! 	def addchoice(self, choice):
! 		if choice not in self.choices:
! 			self.choices.append(choice)
! 			self.choices.sort()
! 		self.update()
  
! 	def addlist(self, list):
! 		self.choices[len(self.choices):] = list
! 		self.choices.sort()
! 		self.update()
  
! 	def entry_cb(self, *e):
! 		self.update()
  
! 	def listbox_cb(self, e):
! 		selection = self.listbox.curselection()
! 		if selection and len(selection) == 1:
! 			name = self.listbox.get(selection[0])
! 			self.show_page(name)
  
! 	def search_cb(self, *e):
! 		self.search_string(self.search.get())
  
! 	def entry_tab(self, e):
! 		self.search.focus_set()
  
! 	def search_tab(self, e):
! 		self.entry.focus_set()
  
! 	def text_tab(self, e):
! 		self.entry.focus_set()
  
! 	def updatelist(self):
! 		key = self.entry.get()
! 		ok = filter(lambda name, key=key, n=len(key): name[:n]==key,
! 			 self.choices)
! 		if not ok:
! 			self.frame.bell()
! 		self.listbox.delete(0, AtEnd())
! 		exactmatch = 0
! 		for item in ok:
! 			if item == key: exactmatch = 1
! 			self.listbox.insert(AtEnd(), item)
! 		if exactmatch:
! 			return key
! 		n = self.listbox.size()
! 		if n == 1:
! 			return self.listbox.get(0)
! 		# Else return None, meaning not a unique selection
  
! 	def update(self):
! 		name = self.updatelist()
! 		if name:
! 			self.show_page(name)
! 			self.entry.delete(0, AtEnd())
! 			self.updatelist()
  
! 	def show_page(self, name):
! 		file = '%s/%s.?' % (self.chaptervar.get(), name)
! 		fp = os.popen('nroff -man %s | ul -i' % file, 'r')
! 		self.text.kill()
! 		self.title['text'] = name
! 		self.text.parsefile(fp)
  
! 	def search_string(self, search):
! 		if not search:
! 			self.frame.bell()
! 			print 'Empty search string'
! 			return
! 		if not self.casevar.get():
! 			map = regex.casefold
! 		else:
! 			map = None
! 		try:
! 			if map:
! 				prog = regex.compile(search, map)
! 			else:
! 				prog = regex.compile(search)
! 		except regex.error, msg:
! 			self.frame.bell()
! 			print 'Regex error:', msg
! 			return
! 		here = self.text.index(AtInsert())
! 		lineno = string.atoi(here[:string.find(here, '.')])
! 		end = self.text.index(AtEnd())
! 		endlineno = string.atoi(end[:string.find(end, '.')])
! 		wraplineno = lineno
! 		found = 0
! 		while 1:
! 			lineno = lineno + 1
! 			if lineno > endlineno:
! 				if wraplineno <= 0:
! 					break
! 				endlineno = wraplineno
! 				lineno = 0
! 				wraplineno = 0
! 			line = self.text.get('%d.0 linestart' % lineno,
! 					     '%d.0 lineend' % lineno)
! 			i = prog.search(line)
! 			if i >= 0:
! 				found = 1
! 				n = max(1, len(prog.group(0)))
! 				try:
! 					self.text.tag_remove('sel',
! 							     AtSelFirst(),
! 							     AtSelLast())
! 				except TclError:
! 					pass
! 				self.text.tag_add('sel',
! 						  '%d.%d' % (lineno, i),
! 						  '%d.%d' % (lineno, i+n))
! 				self.text.mark_set(AtInsert(),
! 						   '%d.%d' % (lineno, i))
! 				self.text.yview_pickplace(AtInsert())
! 				break
! 		if not found:
! 			self.frame.bell()
  
  def main():
! 	root = Tk()
! 	sb = SelectionBox(root)
! 	if sys.argv[1:]:
! 		sb.show_page(sys.argv[1])
! 	root.minsize(1, 1)
! 	root.mainloop()
  
  main()
--- 47,267 ----
  
  def listmanpages(mandir):
!     files = os.listdir(mandir)
!     names = []
!     for file in files:
!         if file[-2:-1] == '.' and  (file[-1] in 'ln123456789'):
!             names.append(file[:-2])
!     names.sort()
!     return names
  
  class SelectionBox:
  
!     def __init__(self, master=None):
!         self.choices = []
  
!         self.frame = Frame(master, name="frame")
!         self.frame.pack(expand=1, fill=BOTH)
!         self.master = self.frame.master
!         self.subframe = Frame(self.frame, name="subframe")
!         self.subframe.pack(expand=0, fill=BOTH)
!         self.leftsubframe = Frame(self.subframe, name='leftsubframe')
!         self.leftsubframe.pack(side=LEFT, expand=1, fill=BOTH)
!         self.rightsubframe = Frame(self.subframe, name='rightsubframe')
!         self.rightsubframe.pack(side=RIGHT, expand=1, fill=BOTH)
!         self.chaptervar = StringVar(master)
!         self.chapter = Menubutton(self.rightsubframe, name='chapter',
!                                   text='Directory', relief=RAISED,
!                                   borderwidth=2)
!         self.chapter.pack(side=TOP)
!         self.chaptermenu = Menu(self.chapter, name='chaptermenu')
!         self.chaptermenu.add_radiobutton(label='C functions',
!                                          value=MAN3DIR,
!                                          variable=self.chaptervar,
!                                          command=self.newchapter)
!         self.chaptermenu.add_radiobutton(label='Tcl/Tk functions',
!                                          value=MANNDIR,
!                                          variable=self.chaptervar,
!                                          command=self.newchapter)
!         self.chapter['menu'] = self.chaptermenu
!         self.listbox = Listbox(self.rightsubframe, name='listbox',
!                                relief=SUNKEN, borderwidth=2,
!                                width=20, height=5)
!         self.listbox.pack(expand=1, fill=BOTH)
!         self.l1 = Button(self.leftsubframe, name='l1',
!                          text='Display manual page named:',
!                          command=self.entry_cb)
!         self.l1.pack(side=TOP)
!         self.entry = Entry(self.leftsubframe, name='entry',
!                             relief=SUNKEN, borderwidth=2,
!                             width=20)
!         self.entry.pack(expand=0, fill=X)
!         self.l2frame = Frame(self.leftsubframe, name='l2frame')
!         self.l2frame.pack(expand=0, fill=NONE)
!         self.l2 = Button(self.l2frame, name='l2',
!                          text='Search regexp:',
!                          command=self.search_cb)
!         self.l2.pack(side=LEFT)
!         self.casevar = BooleanVar()
!         self.casesense = Checkbutton(self.l2frame, name='casesense',
!                                      text='Case sensitive',
!                                      variable=self.casevar,
!                                      relief=FLAT)
!         self.casesense.pack(side=LEFT)
!         self.search = Entry(self.leftsubframe, name='search',
!                             relief=SUNKEN, borderwidth=2,
!                             width=20)
!         self.search.pack(expand=0, fill=X)
!         self.title = Label(self.leftsubframe, name='title',
!                            text='(none)')
!         self.title.pack(side=BOTTOM)
!         self.text = ManPage(self.frame, name='text',
!                             relief=SUNKEN, borderwidth=2,
!                             wrap=NONE, width=72,
!                             selectbackground='pink')
!         self.text.pack(expand=1, fill=BOTH)
  
!         self.entry.bind('<Return>', self.entry_cb)
!         self.search.bind('<Return>', self.search_cb)
!         self.listbox.bind('<Double-1>', self.listbox_cb)
  
!         self.entry.bind('<Tab>', self.entry_tab)
!         self.search.bind('<Tab>', self.search_tab)
!         self.text.bind('<Tab>', self.text_tab)
  
!         self.entry.focus_set()
  
!         self.chaptervar.set(MANNDIR)
!         self.newchapter()
  
!     def newchapter(self):
!         mandir = self.chaptervar.get()
!         self.choices = []
!         self.addlist(listmanpages(mandir))
  
!     def addchoice(self, choice):
!         if choice not in self.choices:
!             self.choices.append(choice)
!             self.choices.sort()
!         self.update()
  
!     def addlist(self, list):
!         self.choices[len(self.choices):] = list
!         self.choices.sort()
!         self.update()
  
!     def entry_cb(self, *e):
!         self.update()
  
!     def listbox_cb(self, e):
!         selection = self.listbox.curselection()
!         if selection and len(selection) == 1:
!             name = self.listbox.get(selection[0])
!             self.show_page(name)
  
!     def search_cb(self, *e):
!         self.search_string(self.search.get())
  
!     def entry_tab(self, e):
!         self.search.focus_set()
  
!     def search_tab(self, e):
!         self.entry.focus_set()
  
!     def text_tab(self, e):
!         self.entry.focus_set()
  
!     def updatelist(self):
!         key = self.entry.get()
!         ok = filter(lambda name, key=key, n=len(key): name[:n]==key,
!                  self.choices)
!         if not ok:
!             self.frame.bell()
!         self.listbox.delete(0, AtEnd())
!         exactmatch = 0
!         for item in ok:
!             if item == key: exactmatch = 1
!             self.listbox.insert(AtEnd(), item)
!         if exactmatch:
!             return key
!         n = self.listbox.size()
!         if n == 1:
!             return self.listbox.get(0)
!         # Else return None, meaning not a unique selection
  
!     def update(self):
!         name = self.updatelist()
!         if name:
!             self.show_page(name)
!             self.entry.delete(0, AtEnd())
!             self.updatelist()
  
!     def show_page(self, name):
!         file = '%s/%s.?' % (self.chaptervar.get(), name)
!         fp = os.popen('nroff -man %s | ul -i' % file, 'r')
!         self.text.kill()
!         self.title['text'] = name
!         self.text.parsefile(fp)
  
!     def search_string(self, search):
!         if not search:
!             self.frame.bell()
!             print 'Empty search string'
!             return
!         if not self.casevar.get():
!             map = regex.casefold
!         else:
!             map = None
!         try:
!             if map:
!                 prog = regex.compile(search, map)
!             else:
!                 prog = regex.compile(search)
!         except regex.error, msg:
!             self.frame.bell()
!             print 'Regex error:', msg
!             return
!         here = self.text.index(AtInsert())
!         lineno = string.atoi(here[:string.find(here, '.')])
!         end = self.text.index(AtEnd())
!         endlineno = string.atoi(end[:string.find(end, '.')])
!         wraplineno = lineno
!         found = 0
!         while 1:
!             lineno = lineno + 1
!             if lineno > endlineno:
!                 if wraplineno <= 0:
!                     break
!                 endlineno = wraplineno
!                 lineno = 0
!                 wraplineno = 0
!             line = self.text.get('%d.0 linestart' % lineno,
!                                  '%d.0 lineend' % lineno)
!             i = prog.search(line)
!             if i >= 0:
!                 found = 1
!                 n = max(1, len(prog.group(0)))
!                 try:
!                     self.text.tag_remove('sel',
!                                          AtSelFirst(),
!                                          AtSelLast())
!                 except TclError:
!                     pass
!                 self.text.tag_add('sel',
!                                   '%d.%d' % (lineno, i),
!                                   '%d.%d' % (lineno, i+n))
!                 self.text.mark_set(AtInsert(),
!                                    '%d.%d' % (lineno, i))
!                 self.text.yview_pickplace(AtInsert())
!                 break
!         if not found:
!             self.frame.bell()
  
  def main():
!     root = Tk()
!     sb = SelectionBox(root)
!     if sys.argv[1:]:
!         sb.show_page(sys.argv[1])
!     root.minsize(1, 1)
!     root.mainloop()
  
  main()

Index: wish.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tkinter/guido/wish.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** wish.py	23 Oct 1995 14:31:46 -0000	1.4
--- wish.py	18 Jul 2004 06:09:09 -0000	1.5
***************
*** 10,27 ****
  
  while 1:
! 	if cmd: prompt = ''
! 	else: prompt = '% '
! 	try:
! 		line = raw_input(prompt)
! 	except EOFError:
! 		break
! 	cmd = cmd + (line + '\n')
! 	if tk.getboolean(tk.call('info', 'complete', cmd)):
! 		tk.record(line)
! 		try:
! 			result = tk.call('eval', cmd)
! 		except _tkinter.TclError, msg:
! 			print 'TclError:', msg
! 		else:
! 			if result: print result
! 		cmd = ''
--- 10,27 ----
  
  while 1:
!     if cmd: prompt = ''
!     else: prompt = '% '
!     try:
!         line = raw_input(prompt)
!     except EOFError:
!         break
!     cmd = cmd + (line + '\n')
!     if tk.getboolean(tk.call('info', 'complete', cmd)):
!         tk.record(line)
!         try:
!             result = tk.call('eval', cmd)
!         except _tkinter.TclError, msg:
!             print 'TclError:', msg
!         else:
!             if result: print result
!         cmd = ''



More information about the Python-checkins mailing list