[Python-checkins] CVS: python/dist/src/Demo/tix/samples Balloon.py,1.1,1.2 BtnBox.py,1.1,1.2 CmpImg.py,1.1,1.2 ComboBox.py,1.1,1.2 Control.py,1.2,1.3 DirList.py,1.1,1.2 DirTree.py,1.1,1.2 NoteBook.py,1.1,1.2 OptMenu.py,1.1,1.2 PopMenu.py,1.1,1.2 SHList1.py,1.2,1.3 SHList2.py,1.2,1.3 Tree.py,1.1,1.2
Martin v. L?wis
loewis@users.sourceforge.net
Sun, 17 Mar 2002 10:19:15 -0800
Update of /cvsroot/python/python/dist/src/Demo/tix/samples
In directory usw-pr-cvs1:/tmp/cvs-serv20863/samples
Modified Files:
Balloon.py BtnBox.py CmpImg.py ComboBox.py Control.py
DirList.py DirTree.py NoteBook.py OptMenu.py PopMenu.py
SHList1.py SHList2.py Tree.py
Log Message:
Patch #485959: Various changes to Tix demos.
Index: Balloon.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Balloon.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Balloon.py 21 Mar 2001 07:42:07 -0000 1.1
--- Balloon.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,4 ****
! #!/usr/local/bin/python
! #
# $Id$
#
--- 1,4 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
! #
# $Id$
#
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 18,45 ****
import Tix
! def RunSample(w):
! status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1)
! status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1)
! # Create two mysterious widgets that need balloon help
! button1 = Tix.Button(w, text='Something Unexpected',
! command=lambda w=w: w.destroy())
! button2 = Tix.Button(w, text='Something Else Unexpected')
! button2['command'] = lambda w=button2: w.destroy()
! button1.pack(side=Tix.TOP, expand=1)
! button2.pack(side=Tix.TOP, expand=1)
! # Create the balloon widget and associate it with the widgets that we want
! # to provide tips for:
! b = Tix.Balloon(w, statusbar=status)
! b.bind_widget(button1, balloonmsg='Close Window',
! statusmsg='Press this button to close this window')
! b.bind_widget(button2, balloonmsg='Self-destruct button',
! statusmsg='Press this button and it will destroy itself')
if __name__ == '__main__':
root = Tix.Tk()
-
RunSample(root)
- root.mainloop()
--- 18,68 ----
import Tix
! TCL_ALL_EVENTS = 0
! def RunSample (root):
! balloon = DemoBalloon(root)
! balloon.mainloop()
! balloon.destroy()
! class DemoBalloon:
! def __init__(self, w):
! self.root = w
! self.exit = -1
! z = w.winfo_toplevel()
! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
!
! status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1)
! status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1)
!
! # Create two mysterious widgets that need balloon help
! button1 = Tix.Button(w, text='Something Unexpected',
! command=self.quitcmd)
! button2 = Tix.Button(w, text='Something Else Unexpected')
! button2['command'] = lambda w=button2: w.destroy()
! button1.pack(side=Tix.TOP, expand=1)
! button2.pack(side=Tix.TOP, expand=1)
!
! # Create the balloon widget and associate it with the widgets that we want
! # to provide tips for:
! b = Tix.Balloon(w, statusbar=status)
!
! b.bind_widget(button1, balloonmsg='Close Window',
! statusmsg='Press this button to close this window')
! b.bind_widget(button2, balloonmsg='Self-destruct button',
! statusmsg='Press this button and it will destroy itself')
!
! def quitcmd (self):
! self.exit = 0
!
! def mainloop(self):
! foundEvent = 1
! while self.exit < 0 and foundEvent > 0:
! foundEvent = self.root.tk.dooneevent(TCL_ALL_EVENTS)
!
! def destroy (self):
! self.root.destroy()
if __name__ == '__main__':
root = Tix.Tk()
RunSample(root)
Index: BtnBox.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/BtnBox.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BtnBox.py 21 Mar 2001 07:42:07 -0000 1.1
--- BtnBox.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,3 ****
! #!/usr/local/bin/python
#
# $Id$
--- 1,3 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
Index: CmpImg.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/CmpImg.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CmpImg.py 21 Mar 2001 07:42:07 -0000 1.1
--- CmpImg.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,3 ****
! #!/usr/local/bin/python
#
# $Id$
--- 1,3 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
Index: ComboBox.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/ComboBox.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ComboBox.py 21 Mar 2001 07:42:07 -0000 1.1
--- ComboBox.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,3 ****
! #!/usr/local/bin/python
#
# $Id$
--- 1,3 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 86,96 ****
def select_month(event=None):
! print "Month =", demo_month.get()
def select_year(event=None):
! print "Year =", demo_year.get()
def ok_command(w):
! print "Month =", demo_month.get(), ", Year=", demo_year.get()
w.destroy()
--- 86,98 ----
def select_month(event=None):
! # tixDemo:Status "Month = %s" % demo_month.get()
! pass
def select_year(event=None):
! # tixDemo:Status "Year = %s" % demo_year.get()
! pass
def ok_command(w):
! # tixDemo:Status "Month = %s, Year= %s" % (demo_month.get(), demo_year.get())
w.destroy()
Index: Control.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Control.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Control.py 11 May 2001 19:52:03 -0000 1.2
--- Control.py 17 Mar 2002 18:19:13 -0000 1.3
***************
*** 1,4 ****
! #!/usr/local/bin/python
! #
# $Id$
#
--- 1,4 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
! #
# $Id$
#
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 18,72 ****
# integer values; one lets you select floating point values and the last
# one lets you select a few names.
! #
import Tix
! def RunSample(w):
! global demo_maker, demo_thrust, demo_num_engines
! demo_maker = Tix.StringVar()
! demo_thrust = Tix.DoubleVar()
! demo_num_engines = Tix.IntVar()
! demo_maker.set('P&W')
! demo_thrust.set(20000.0)
! demo_num_engines.set(2)
! top = Tix.Frame(w, bd=1, relief=Tix.RAISED)
! # $w.top.a allows only integer values
! #
! # [Hint] The -options switch sets the options of the subwidgets.
! # [Hint] We set the label.width subwidget option of the Controls to
! # be 16 so that their labels appear to be aligned.
! #
! a = Tix.Control(top, label='Number of Engines: ', integer=1,
! variable=demo_num_engines, min=1, max=4,
! options='entry.width 10 label.width 20 label.anchor e')
!
! b = Tix.Control(top, label='Thrust: ', integer=0,
! min='10000.0', max='60000.0', step=500,
! variable=demo_thrust,
! options='entry.width 10 label.width 20 label.anchor e')
! c = Tix.Control(top, label='Engine Maker: ', value='P&W',
! variable=demo_maker,
! options='entry.width 10 label.width 20 label.anchor e')
! # We can't define these in the init because the widget 'c' doesn't
! # exist yet and we need to reference it
! c['incrcmd'] = lambda w=c: adjust_maker(w, 1)
! c['decrcmd'] = lambda w=c: adjust_maker(w, -1)
! c['validatecmd'] = lambda w=c: validate_maker(w)
! a.pack(side=Tix.TOP, anchor=Tix.W)
! b.pack(side=Tix.TOP, anchor=Tix.W)
! c.pack(side=Tix.TOP, anchor=Tix.W)
! box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
! box.add('ok', text='Ok', underline=0, width=6,
! command=lambda w=w: ok_command(w))
! box.add('cancel', text='Cancel', underline=0, width=6,
! command=lambda w=w: w.destroy())
! box.pack(side=Tix.BOTTOM, fill=Tix.X)
! top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
maker_list = ['P&W', 'GE', 'Rolls Royce']
--- 18,97 ----
# integer values; one lets you select floating point values and the last
# one lets you select a few names.
!
import Tix
! TCL_ALL_EVENTS = 0
! def RunSample (root):
! control = DemoControl(root)
! control.mainloop()
! control.destroy()
! class DemoControl:
! def __init__(self, w):
! self.root = w
! self.exit = -1
! global demo_maker, demo_thrust, demo_num_engines
! demo_maker = Tix.StringVar()
! demo_thrust = Tix.DoubleVar()
! demo_num_engines = Tix.IntVar()
! demo_maker.set('P&W')
! demo_thrust.set(20000.0)
! demo_num_engines.set(2)
! top = Tix.Frame(w, bd=1, relief=Tix.RAISED)
! # $w.top.a allows only integer values
! #
! # [Hint] The -options switch sets the options of the subwidgets.
! # [Hint] We set the label.width subwidget option of the Controls to
! # be 16 so that their labels appear to be aligned.
! #
! a = Tix.Control(top, label='Number of Engines: ', integer=1,
! variable=demo_num_engines, min=1, max=4,
! options='entry.width 10 label.width 20 label.anchor e')
! b = Tix.Control(top, label='Thrust: ', integer=0,
! min='10000.0', max='60000.0', step=500,
! variable=demo_thrust,
! options='entry.width 10 label.width 20 label.anchor e')
!
! c = Tix.Control(top, label='Engine Maker: ', value='P&W',
! variable=demo_maker,
! options='entry.width 10 label.width 20 label.anchor e')
!
! # We can't define these in the init because the widget 'c' doesn't
! # exist yet and we need to reference it
! c['incrcmd'] = lambda w=c: adjust_maker(w, 1)
! c['decrcmd'] = lambda w=c: adjust_maker(w, -1)
! c['validatecmd'] = lambda w=c: validate_maker(w)
!
! a.pack(side=Tix.TOP, anchor=Tix.W)
! b.pack(side=Tix.TOP, anchor=Tix.W)
! c.pack(side=Tix.TOP, anchor=Tix.W)
!
! box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
! box.add('ok', text='Ok', underline=0, width=6,
! command=self.okcmd)
! box.add('cancel', text='Cancel', underline=0, width=6,
! command=self.quitcmd)
! box.pack(side=Tix.BOTTOM, fill=Tix.X)
! top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
!
! def okcmd (self):
! # tixDemo:Status "Selected %d of %s engines each of thrust %d", (demo_num_engines.get(), demo_maker.get(), demo_thrust.get())
! self.quitcmd()
!
! def quitcmd (self):
! self.exit = 0
!
! def mainloop(self):
! while self.exit < 0:
! self.root.tk.dooneevent(TCL_ALL_EVENTS)
!
! def destroy (self):
! self.root.destroy()
maker_list = ['P&W', 'GE', 'Rolls Royce']
***************
*** 93,102 ****
return maker_list[i]
- def ok_command(w):
- print "Selected", demo_num_engines.get(), "of", demo_maker.get(), " engines each of thrust", demo_thrust.get()
- w.destroy()
-
if __name__ == '__main__':
root = Tix.Tk()
RunSample(root)
- root.mainloop()
--- 118,122 ----
Index: DirList.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/DirList.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DirList.py 11 Nov 2001 14:07:37 -0000 1.1
--- DirList.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "widget": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 20,32 ****
from Tkconstants import *
- TCL_DONT_WAIT = 1<<1
- TCL_WINDOW_EVENTS = 1<<2
- TCL_FILE_EVENTS = 1<<3
- TCL_TIMER_EVENTS = 1<<4
- TCL_IDLE_EVENTS = 1<<5
TCL_ALL_EVENTS = 0
def RunSample (root):
- global dirlist
dirlist = DemoDirList(root)
dirlist.mainloop()
--- 20,26 ----
***************
*** 39,43 ****
z = w.winfo_toplevel()
! z.wm_title('Tix.DirList Widget Demo')
# Create the tixDirList and the tixLabelEntry widgets on the on the top
--- 33,37 ----
z = w.winfo_toplevel()
! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
# Create the tixDirList and the tixLabelEntry widgets on the on the top
***************
*** 99,103 ****
box.pack( anchor='s', fill='x', side=BOTTOM)
- z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
def copy_name (self, dir, ent):
--- 93,96 ----
***************
*** 109,118 ****
def okcmd (self):
! # tixDemo:Status "You have selected the directory" + $self.dlist_dir
!
self.quitcmd()
def quitcmd (self):
- # self.root.destroy()
self.exit = 0
--- 102,109 ----
def okcmd (self):
! # tixDemo:Status "You have selected the directory" + self.dlist_dir
self.quitcmd()
def quitcmd (self):
self.exit = 0
***************
*** 120,124 ****
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
- # self.root.tk.dooneevent(TCL_DONT_WAIT)
def destroy (self):
--- 111,114 ----
***************
*** 126,130 ****
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "widget".
#
if __name__== '__main__' :
--- 116,120 ----
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
Index: DirTree.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/DirTree.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DirTree.py 11 Nov 2001 14:07:37 -0000 1.1
--- DirTree.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "widget": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 20,33 ****
from Tkconstants import *
! def RunSample (w):
! DemoDirTree(w)
class DemoDirTree:
def __init__(self, w):
self.root = w
z = w.winfo_toplevel()
! z.wm_title('Tix.DirTree Widget Demo')
!
# Create the tixDirTree and the tixLabelEntry widgets on the on the top
# of the dialog box
--- 20,38 ----
from Tkconstants import *
! TCL_ALL_EVENTS = 0
!
! def RunSample (root):
! dirtree = DemoDirTree(root)
! dirtree.mainloop()
! dirtree.destroy()
class DemoDirTree:
def __init__(self, w):
self.root = w
+ self.exit = -1
z = w.winfo_toplevel()
! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
!
# Create the tixDirTree and the tixLabelEntry widgets on the on the top
# of the dialog box
***************
*** 91,108 ****
def okcmd (self):
! # tixDemo:Status "You have selected the directory" + $self.dlist_dir
!
self.quitcmd()
def quitcmd (self):
self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "widget".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
- root.mainloop()
- root.destroy()
--- 96,118 ----
def okcmd (self):
! # tixDemo:Status "You have selected the directory" + self.dlist_dir
self.quitcmd()
def quitcmd (self):
+ # tixDemo:Status "You have selected the directory" + self.dlist_dir
+ self.exit = 0
+
+ def mainloop(self):
+ while self.exit < 0:
+ self.root.tk.dooneevent(TCL_ALL_EVENTS)
+
+ def destroy (self):
self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
Index: NoteBook.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/NoteBook.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NoteBook.py 21 Mar 2001 07:42:07 -0000 1.1
--- NoteBook.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,3 ****
! #!/usr/local/bin/python
#
# $Id$
--- 1,3 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
Index: OptMenu.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/OptMenu.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** OptMenu.py 21 Mar 2001 07:42:07 -0000 1.1
--- OptMenu.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,3 ****
! #!/usr/local/bin/python
#
# $Id$
--- 1,3 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 60,64 ****
def ok_command(w):
! print "Convert file from", demo_opt_from.get(), " to", demo_opt_to.get()
w.destroy()
--- 60,64 ----
def ok_command(w):
! # tixDemo:Status "Convert file from %s to %s" % ( demo_opt_from.get(), demo_opt_to.get())
w.destroy()
Index: PopMenu.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/PopMenu.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PopMenu.py 21 Mar 2001 07:42:07 -0000 1.1
--- PopMenu.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,9 ****
! # Tix Demostration Program
! #
! # $Id$
#
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "widget": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 1,10 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
+ # $Id$
+ #
+ # Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
Index: SHList1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/SHList1.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SHList1.py 11 Nov 2001 14:07:37 -0000 1.2
--- SHList1.py 17 Mar 2002 18:19:13 -0000 1.3
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 16,108 ****
import Tix
! def RunSample (w) :
! # We create the frame and the ScrolledHList widget
! # at the top of the dialog box
! #
! top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
! # Put a simple hierachy into the HList (two levels). Use colors and
! # separator widgets (frames) to make the list look fancy
! #
! top.a = Tix.ScrolledHList(top)
! top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)
! # This is our little relational database
! #
! bosses = [
! ('jeff', 'Jeff Waxman'),
! ('john', 'John Lee'),
! ('peter', 'Peter Kenson')
! ]
! employees = [
! ('alex', 'john', 'Alex Kellman'),
! ('alan', 'john', 'Alan Adams'),
! ('andy', 'peter', 'Andreas Crawford'),
! ('doug', 'jeff', 'Douglas Bloom'),
! ('jon', 'peter', 'Jon Baraki'),
! ('chris', 'jeff', 'Chris Geoffrey'),
! ('chuck', 'jeff', 'Chuck McLean')
! ]
! hlist=top.a.hlist
! # Let configure the appearance of the HList subwidget
! #
! hlist.config( separator='.', width=25, drawbranch=0, indent=10)
! count=0
! for boss,name in bosses :
! if count :
! f=Tix.Frame(hlist, name='sep%d' % count, height=2, width=150,
! bd=2, relief=Tix.SUNKEN )
! hlist.add_child( itemtype=Tix.WINDOW,
! window=f, state=Tix.DISABLED )
!
! hlist.add(boss, itemtype=Tix.TEXT, text=name)
! count = count+1
!
! for person,boss,name in employees :
! # '.' is the separator character we chose above
! #
! key= boss + '.' + person
! # ^^^^ ^^^^^^
! # parent entryPath / child's name
- hlist.add( key, text=name )
! # [Hint] Make sure the keys (e.g. 'boss.person') you choose
! # are unique names. If you cannot be sure of this (because of
! # the structure of your database, e.g.) you can use the
! # "add_child" command instead:
! #
! # hlist.addchild( boss, text=name)
! # ^^^^
! # parent entryPath
! # Use a ButtonBox to hold the buttons.
! #
! box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
! box.add( 'ok', text='Ok', underline=0, width=6,
! command = lambda w=w: w.quit() )
- box.add( 'cancel', text='Cancel', underline=0, width=6,
- command = lambda w=w: w.quit() )
! box.pack( side=Tix.BOTTOM, fill=Tix.X)
! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "widget".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
! root.mainloop()
! root.destroy()
--- 16,132 ----
import Tix
! TCL_ALL_EVENTS = 0
! def RunSample (root):
! shlist = DemoSHList(root)
! shlist.mainloop()
! shlist.destroy()
!
! class DemoSHList:
! def __init__(self, w):
! self.root = w
! self.exit = -1
! z = w.winfo_toplevel()
! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
!
! # We create the frame and the ScrolledHList widget
! # at the top of the dialog box
! #
! top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
+ # Put a simple hierachy into the HList (two levels). Use colors and
+ # separator widgets (frames) to make the list look fancy
+ #
+ top.a = Tix.ScrolledHList(top)
+ top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)
! # This is our little relational database
! #
! bosses = [
! ('jeff', 'Jeff Waxman'),
! ('john', 'John Lee'),
! ('peter', 'Peter Kenson')
! ]
! employees = [
! ('alex', 'john', 'Alex Kellman'),
! ('alan', 'john', 'Alan Adams'),
! ('andy', 'peter', 'Andreas Crawford'),
! ('doug', 'jeff', 'Douglas Bloom'),
! ('jon', 'peter', 'Jon Baraki'),
! ('chris', 'jeff', 'Chris Geoffrey'),
! ('chuck', 'jeff', 'Chuck McLean')
! ]
! hlist=top.a.hlist
! # Let configure the appearance of the HList subwidget
! #
! hlist.config( separator='.', width=25, drawbranch=0, indent=10)
! count=0
! for boss,name in bosses :
! if count :
! f=Tix.Frame(hlist, name='sep%d' % count, height=2, width=150,
! bd=2, relief=Tix.SUNKEN )
! hlist.add_child( itemtype=Tix.WINDOW,
! window=f, state=Tix.DISABLED )
! hlist.add(boss, itemtype=Tix.TEXT, text=name)
! count = count+1
! for person,boss,name in employees :
! # '.' is the separator character we chose above
! #
! key= boss + '.' + person
! # ^^^^ ^^^^^^
! # parent entryPath / child's name
+ hlist.add( key, text=name )
! # [Hint] Make sure the keys (e.g. 'boss.person') you choose
! # are unique names. If you cannot be sure of this (because of
! # the structure of your database, e.g.) you can use the
! # "add_child" command instead:
! #
! # hlist.addchild( boss, text=name)
! # ^^^^
! # parent entryPath
! # Use a ButtonBox to hold the buttons.
! #
! box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
! box.add( 'ok', text='Ok', underline=0, width=6,
! command = self.okcmd)
!
! box.add( 'cancel', text='Cancel', underline=0, width=6,
! command = self.quitcmd)
!
! box.pack( side=Tix.BOTTOM, fill=Tix.X)
! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
!
! def okcmd (self):
! self.quitcmd()
!
! def quitcmd (self):
! self.exit = 0
!
! def mainloop(self):
! while self.exit < 0:
! self.root.tk.dooneevent(TCL_ALL_EVENTS)
!
! def destroy (self):
! self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
!
Index: SHList2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/SHList2.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SHList2.py 11 Nov 2001 14:07:37 -0000 1.2
--- SHList2.py 17 Mar 2002 18:19:13 -0000 1.3
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the PyTix demo program "tixwidget": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidget": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
***************
*** 19,145 ****
import Tix
! def RunSample (w) :
! # We create the frame and the ScrolledHList widget
! # at the top of the dialog box
! #
! top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
! # Put a simple hierachy into the HList (two levels). Use colors and
! # separator widgets (frames) to make the list look fancy
! #
! top.a = Tix.ScrolledHList(top, options='hlist.columns 3 hlist.header 1' )
! top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)
! hlist=top.a.hlist
! # Create the title for the HList widget
! # >> Notice that we have set the hlist.header subwidget option to true
! # so that the header is displayed
! #
! boldfont=hlist.tk.call('tix','option','get','bold_font')
! # First some styles for the headers
! style={}
! style['header'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top,
! anchor=Tix.CENTER, padx=8, pady=2, font = boldfont )
! hlist.header_create(0, itemtype=Tix.TEXT, text='Name',
! style=style['header'])
! hlist.header_create(1, itemtype=Tix.TEXT, text='Position',
! style=style['header'])
! # Notice that we use 3 columns in the hlist widget. This way when the user
! # expands the windows wide, the right side of the header doesn't look
! # chopped off. The following line ensures that the 3 column header is
! # not shown unless the hlist window is wider than its contents.
! #
! hlist.column_width(2,0)
! # This is our little relational database
! #
! boss = ('doe', 'John Doe', 'Director')
! managers = [
! ('jeff', 'Jeff Waxman', 'Manager'),
! ('john', 'John Lee', 'Manager'),
! ('peter', 'Peter Kenson', 'Manager')
! ]
! employees = [
! ('alex', 'john', 'Alex Kellman', 'Clerk'),
! ('alan', 'john', 'Alan Adams', 'Clerk'),
! ('andy', 'peter', 'Andreas Crawford', 'Salesman'),
! ('doug', 'jeff', 'Douglas Bloom', 'Clerk'),
! ('jon', 'peter', 'Jon Baraki', 'Salesman'),
! ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'),
! ('chuck', 'jeff', 'Chuck McLean', 'Cleaner')
! ]
! style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top)
! style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=top)
! style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top)
! style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=top)
! # Let configure the appearance of the HList subwidget
! #
! hlist.config(separator='.', width=25, drawbranch=0, indent=10)
! hlist.column_width(0, chars=20)
! # Create the boss
! #
! hlist.add ('.', itemtype=Tix.TEXT, text=boss[1],
! style=style['mgr_name'])
! hlist.item_create('.', 1, itemtype=Tix.TEXT, text=boss[2],
! style=style['mgr_posn'])
! # Create the managers
! #
! for key,name,posn in managers :
! e= '.'+ key
! hlist.add(e, itemtype=Tix.TEXT, text=name,
! style=style['mgr_name'])
! hlist.item_create(e, 1, itemtype=Tix.TEXT, text=posn,
! style=style['mgr_posn'])
! for key,mgr,name,posn in employees :
! # "." is the separator character we chose above
! entrypath = '.' + mgr + '.' + key
! # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
! # parent entryPath / child's name
! hlist.add(entrypath, text=name, style=style['empl_name'])
! hlist.item_create(entrypath, 1, itemtype=Tix.TEXT,
! text = posn, style = style['empl_posn'] )
!
- # Use a ButtonBox to hold the buttons.
- #
- box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
- box.add( 'ok', text='Ok', underline=0, width=6,
- command = lambda w=w: w.quit() )
! box.add( 'cancel', text='Cancel', underline=0, width=6,
! command = lambda w=w: w.quit() )
! box.pack( side=Tix.BOTTOM, fill=Tix.X)
! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "widget".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
! root.mainloop()
! root.destroy()
--- 19,169 ----
import Tix
! TCL_ALL_EVENTS = 0
! def RunSample (root):
! shlist = DemoSHList(root)
! shlist.mainloop()
! shlist.destroy()
!
! class DemoSHList:
! def __init__(self, w):
! self.root = w
! self.exit = -1
! z = w.winfo_toplevel()
! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
!
! # We create the frame and the ScrolledHList widget
! # at the top of the dialog box
! #
! top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
! # Put a simple hierachy into the HList (two levels). Use colors and
! # separator widgets (frames) to make the list look fancy
! #
! top.a = Tix.ScrolledHList(top, options='hlist.columns 3 hlist.header 1' )
! top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)
! hlist=top.a.hlist
! # Create the title for the HList widget
! # >> Notice that we have set the hlist.header subwidget option to true
! # so that the header is displayed
! #
! boldfont=hlist.tk.call('tix','option','get','bold_font')
! # First some styles for the headers
! style={}
! style['header'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist,
! anchor=Tix.CENTER, padx=8, pady=2, font = boldfont )
! hlist.header_create(0, itemtype=Tix.TEXT, text='Name',
! style=style['header'])
! hlist.header_create(1, itemtype=Tix.TEXT, text='Position',
! style=style['header'])
! # Notice that we use 3 columns in the hlist widget. This way when the user
! # expands the windows wide, the right side of the header doesn't look
! # chopped off. The following line ensures that the 3 column header is
! # not shown unless the hlist window is wider than its contents.
! #
! hlist.column_width(2,0)
! # This is our little relational database
! #
! boss = ('doe', 'John Doe', 'Director')
! managers = [
! ('jeff', 'Jeff Waxman', 'Manager'),
! ('john', 'John Lee', 'Manager'),
! ('peter', 'Peter Kenson', 'Manager')
! ]
! employees = [
! ('alex', 'john', 'Alex Kellman', 'Clerk'),
! ('alan', 'john', 'Alan Adams', 'Clerk'),
! ('andy', 'peter', 'Andreas Crawford', 'Salesman'),
! ('doug', 'jeff', 'Douglas Bloom', 'Clerk'),
! ('jon', 'peter', 'Jon Baraki', 'Salesman'),
! ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'),
! ('chuck', 'jeff', 'Chuck McLean', 'Cleaner')
! ]
! style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)
! style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist)
! style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)
! style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist)
! # Let configure the appearance of the HList subwidget
! #
! hlist.config(separator='.', width=25, drawbranch=0, indent=10)
! hlist.column_width(0, chars=20)
! # Create the boss
! #
! hlist.add ('.', itemtype=Tix.TEXT, text=boss[1],
! style=style['mgr_name'])
! hlist.item_create('.', 1, itemtype=Tix.TEXT, text=boss[2],
! style=style['mgr_posn'])
! # Create the managers
! #
! for key,name,posn in managers :
! e= '.'+ key
! hlist.add(e, itemtype=Tix.TEXT, text=name,
! style=style['mgr_name'])
! hlist.item_create(e, 1, itemtype=Tix.TEXT, text=posn,
! style=style['mgr_posn'])
! for key,mgr,name,posn in employees :
! # "." is the separator character we chose above
! entrypath = '.' + mgr + '.' + key
! # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
! # parent entryPath / child's name
! hlist.add(entrypath, text=name, style=style['empl_name'])
! hlist.item_create(entrypath, 1, itemtype=Tix.TEXT,
! text = posn, style = style['empl_posn'] )
! # Use a ButtonBox to hold the buttons.
! #
! box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
! box.add( 'ok', text='Ok', underline=0, width=6,
! command = self.okcmd )
! box.add( 'cancel', text='Cancel', underline=0, width=6,
! command = self.quitcmd )
!
! box.pack( side=Tix.BOTTOM, fill=Tix.X)
! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
!
! def okcmd (self):
! self.quitcmd()
!
! def quitcmd (self):
! self.exit = 0
!
! def mainloop(self):
! while self.exit < 0:
! self.root.tk.dooneevent(TCL_ALL_EVENTS)
!
! def destroy (self):
! self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
! # outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
!
Index: Tree.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Tree.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Tree.py 21 Mar 2001 07:42:07 -0000 1.1
--- Tree.py 17 Mar 2002 18:19:13 -0000 1.2
***************
*** 1,3 ****
! #!/usr/local/bin/python
#
# $Id$
--- 1,3 ----
! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
***************
*** 6,10 ****
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
--- 6,10 ----
#
# This sample program is structured in such a way so that it can be
! # executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone