[Python-checkins] CVS: python/dist/src/Demo/tix tixwidgets.py,1.3,1.4
Martin v. L?wis
loewis@users.sourceforge.net
Sun, 25 Nov 2001 06:50:57 -0800
Update of /cvsroot/python/python/dist/src/Demo/tix
In directory usw-pr-cvs1:/tmp/cvs-serv28416/Demo/tix
Modified Files:
tixwidgets.py
Log Message:
Properly set static options for tixBalloon and tixResizeHandle.
Expose Tix.ResizeHandle.{detach_widget,hide,show}.
Update Tix demos.
Index: tixwidgets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/tix/tixwidgets.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tixwidgets.py 2001/11/11 14:07:37 1.3
--- tixwidgets.py 2001/11/25 14:50:55 1.4
***************
*** 10,17 ****
# you have installed Python & Tix properly, you can execute this as
#
! # % python tixwidget.py
#
! import os, sys, Tix
from Tkconstants import *
--- 10,17 ----
# you have installed Python & Tix properly, you can execute this as
#
! # % python tixwidgets.py
#
! import os, os.path, sys, Tix
from Tkconstants import *
***************
*** 61,67 ****
file.pack(side=LEFT)
help.pack(side=RIGHT)
! fm = Tix.Menu(file)
file['menu'] = fm
! hm = Tix.Menu(help)
help['menu'] = hm
--- 61,67 ----
file.pack(side=LEFT)
help.pack(side=RIGHT)
! fm = Tix.Menu(file, tearoff=0)
file['menu'] = fm
! hm = Tix.Menu(help, tearoff=0)
help['menu'] = hm
***************
*** 70,74 ****
command=lambda w=w: w.tk.eval('console show'))
! fm.add_command(label='Exit', underline=1, accelerator='Ctrl+X',
command = lambda self=self: self.quitcmd () )
hm.add_checkbutton(label='BalloonHelp', underline=0, command=ToggleHelp,
--- 70,74 ----
command=lambda w=w: w.tk.eval('console show'))
! fm.add_command(label='Exit', underline=1,
command = lambda self=self: self.quitcmd () )
hm.add_checkbutton(label='BalloonHelp', underline=0, command=ToggleHelp,
***************
*** 129,151 ****
def quitcmd (self):
! # self.root.destroy()
self.exit = 0
def loop(self):
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
! # self.root.tk.dooneevent(TCL_DONT_WAIT)
def destroy (self):
self.root.destroy()
! def RunMain(top):
! global demo, root
! demo = Demo(top)
- # top.withdraw()
- # root = Tix.Toplevel()
- root = top
demo.build()
demo.loop()
--- 129,169 ----
def quitcmd (self):
! """Quit our mainloop. It is up to you to call root.destroy() after."""
self.exit = 0
def loop(self):
+ import tkMessageBox, traceback
+ while self.exit < 0:
+ try:
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
! except SystemExit:
! #print 'Exit'
! self.exit = 1
! break
! except KeyboardInterrupt:
! if tkMessageBox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
! # self.tk.eval('exit')
! return
! else:
! pass
! continue
! except:
! t, v, tb = sys.exc_info()
! text = ""
! for line in traceback.format_exception(t,v,tb):
! text += line + '\n'
! try: tkMessageBox.showerror ('Error', text)
! except: pass
! tkinspect_quit (1)
def destroy (self):
self.root.destroy()
! def RunMain(root):
! global demo
! demo = Demo(root)
demo.build()
demo.loop()
***************
*** 501,506 ****
rh.attach_widget(list)
def MkSWindow(w):
! global demo
top = Tix.Frame(w, width=330, height=330)
--- 519,533 ----
rh.attach_widget(list)
+ # See below why this is necessary.
+ global image1
+ image1 = None
def MkSWindow(w):
! global demo, image1
!
! text = 'The TixScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.'
!
! file = os.path.join(demo.dir, 'bitmaps', 'tix.gif')
! if not os.path.isfile(file):
! text += ' (Image missing)'
top = Tix.Frame(w, width=330, height=330)
***************
*** 508,515 ****
msg = Tix.Message(top,
relief=Tix.FLAT, width=200, anchor=Tix.N,
! text='The TixScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.')
win = Tix.ScrolledWindow(top, scrollbar='auto')
! image = Tix.Image('photo', file=demo.dir + "/bitmaps/tix.gif")
! lbl = Tix.Label(win.window, image=image)
lbl.pack(expand=1, fill=Tix.BOTH)
--- 535,548 ----
msg = Tix.Message(top,
relief=Tix.FLAT, width=200, anchor=Tix.N,
! text=text)
!
win = Tix.ScrolledWindow(top, scrollbar='auto')
!
! # This image is not showing up under Python unless it is set to a
! # global variable - no problem under Tcl. I assume it is being garbage
! # collected some how, even though the tcl command 'image names' shows
! # that as far as Tcl is concerned, the image exists and is called pyimage1.
! image1 = Tix.Image('photo', file=file)
! lbl = Tix.Label(win.window, image=image1)
lbl.pack(expand=1, fill=Tix.BOTH)
***************
*** 582,586 ****
relief=Tix.FLAT, width=240, anchor=Tix.N,
text='The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.')
! group = Tix.Label(w, text='Newsgroup: comp.lang.python')
pane = Tix.PanedWindow(w, orientation='vertical')
--- 615,620 ----
relief=Tix.FLAT, width=240, anchor=Tix.N,
text='The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.')
! group = Tix.LabelEntry(w, label='Newsgroup:', options='entry.width 25')
! group.entry.insert(0,'comp.lang.python')
pane = Tix.PanedWindow(w, orientation='vertical')
***************
*** 590,605 ****
text = Tix.ScrolledText(p2)
! list.listbox.insert(Tix.END, " 12324 Re: TK is good for your health")
! list.listbox.insert(Tix.END, "+ 12325 Re: TK is good for your health")
! list.listbox.insert(Tix.END, "+ 12326 Re: Tix is even better for your health (Was: TK is good...)")
! list.listbox.insert(Tix.END, " 12327 Re: Tix is even better for your health (Was: TK is good...)")
! list.listbox.insert(Tix.END, "+ 12328 Re: Tix is even better for your health (Was: TK is good...)")
! list.listbox.insert(Tix.END, " 12329 Re: Tix is even better for your health (Was: TK is good...)")
! list.listbox.insert(Tix.END, "+ 12330 Re: Tix is even better for your health (Was: TK is good...)")
text.text['bg'] = list.listbox['bg']
text.text['wrap'] = 'none'
text.text.insert(Tix.END, """
! Mon, 19 Jun 1995 11:39:52 comp.lang.tcl Thread 34 of 220
Lines 353 A new way to put text and bitmaps together iNo responses
ioi@blue.seas.upenn.edu Ioi K. Lam at University of Pennsylvania
--- 624,639 ----
text = Tix.ScrolledText(p2)
! list.listbox.insert(Tix.END, " 12324 Re: Tkinter is good for your health")
! list.listbox.insert(Tix.END, "+ 12325 Re: Tkinter is good for your health")
! list.listbox.insert(Tix.END, "+ 12326 Re: Tix is even better for your health (Was: Tkinter is good...)")
! list.listbox.insert(Tix.END, " 12327 Re: Tix is even better for your health (Was: Tkinter is good...)")
! list.listbox.insert(Tix.END, "+ 12328 Re: Tix is even better for your health (Was: Tkinter is good...)")
! list.listbox.insert(Tix.END, " 12329 Re: Tix is even better for your health (Was: Tkinter is good...)")
! list.listbox.insert(Tix.END, "+ 12330 Re: Tix is even better for your health (Was: Tkinter is good...)")
text.text['bg'] = list.listbox['bg']
text.text['wrap'] = 'none'
text.text.insert(Tix.END, """
! Mon, 19 Jun 1995 11:39:52 comp.lang.python Thread 34 of 220
Lines 353 A new way to put text and bitmaps together iNo responses
ioi@blue.seas.upenn.edu Ioi K. Lam at University of Pennsylvania
***************
*** 718,721 ****
--- 752,756 ----
'Notebook' : 'NoteBook',
'Option Menu' : 'OptMenu',
+ 'Paned Window' : 'PanedWin',
'Popup Menu' : 'PopMenu',
'ScrolledHList (1)' : 'SHList1',
***************
*** 796,801 ****
## set manager {
##na {f ListNoteBook ListNBK.tcl }
! ## {f NoteBook NoteBook.tcl }
! ## {f PanedWindow PanedWin.tcl }
## }
##
--- 831,836 ----
## set manager {
##na {f ListNoteBook ListNBK.tcl }
! ##done {f NoteBook NoteBook.tcl }
! ##done {f PanedWindow PanedWin.tcl }
## }
##
***************
*** 818,822 ****
stypes['widget'] = ['Balloon', 'Button Box', 'Combo Box', 'Control',
'Directory List', 'Directory Tree',
! 'Notebook', 'Option Menu', 'Popup Menu',
'ScrolledHList (1)', 'ScrolledHList (2)', 'Tree (dynamic)']
stypes['image'] = ['Compound Image']
--- 853,857 ----
stypes['widget'] = ['Balloon', 'Button Box', 'Combo Box', 'Control',
'Directory List', 'Directory Tree',
! 'Notebook', 'Option Menu', 'Popup Menu', 'Paned Window',
'ScrolledHList (1)', 'ScrolledHList (2)', 'Tree (dynamic)']
stypes['image'] = ['Compound Image']
***************
*** 827,861 ****
if not prefix:
prefix = ''
! w.option_add('*' + prefix + '*TixLabelFrame*label.padX', 4)
! lab = Tix.Label(w, text='Select a sample program:', anchor=Tix.W)
! lab1 = Tix.Label(w, text='Source:', anchor=Tix.W)
! slb = Tix.ScrolledHList(w, options='listbox.exportSelection 0')
! slb.hlist['command'] = lambda args=0, w=w,slb=slb: Sample_Action(w, slb, 'run')
! slb.hlist['browsecmd'] = lambda args=0, w=w,slb=slb: Sample_Action(w, slb, 'browse')
! stext = Tix.ScrolledText(w, name='stext')
font = root.tk.eval('tix option get fixed_font')
stext.text.config(font=font)
- # stext.text.bind('<1>', stext.text.focus())
stext.text.bind('<Up>', lambda w=stext.text: w.yview(scroll='-1 unit'))
stext.text.bind('<Down>', lambda w=stext.text: w.yview(scroll='1 unit'))
stext.text.bind('<Left>', lambda w=stext.text: w.xview(scroll='-1 unit'))
stext.text.bind('<Right>', lambda w=stext.text: w.xview(scroll='1 unit'))
! run = Tix.Button(w, text='Run ...', name='run', command=lambda args=0, w=w,slb=slb: Sample_Action(w, slb, 'run'))
! view = Tix.Button(w, text='View Source ...', name='view', command=lambda args=0,w=w,slb=slb: Sample_Action(w, slb, 'view'))
! lab.form(top=0, left=0, right='&'+str(slb))
! slb.form(left=0, top=lab, bottom=-4)
! lab1.form(left='&'+str(stext), top=0, right='&'+str(stext), bottom=stext)
! run.form(left=str(slb)+' 30', bottom=-4)
! view.form(left=run, bottom=-4)
! stext.form(bottom=str(run)+' -5', left='&'+str(run), right='-0', top='&'+str(slb))
stext.text['bg'] = slb.hlist['bg']
stext.text['state'] = 'disabled'
stext.text['wrap'] = 'none'
slb.hlist['separator'] = '.'
--- 862,905 ----
if not prefix:
prefix = ''
! else:
! prefix = '*' + prefix
! w.option_add(prefix + '*TixLabelFrame*label.padX', 4)
! pane = Tix.PanedWindow(w, orientation='horizontal')
! pane.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH)
! f1 = pane.add('list', expand='1')
! f2 = pane.add('text', expand='5')
! f1['relief'] = 'flat'
! f2['relief'] = 'flat'
! lab = Tix.Label(f1, text='Select a sample program:', anchor=Tix.W)
! lab.pack(side=Tix.TOP, expand=0, fill=Tix.X, padx=5, pady=5)
! lab1 = Tix.Label(f2, text='Source:', anchor=Tix.W)
! lab1.pack(side=Tix.TOP, expand=0, fill=Tix.X, padx=5, pady=5)
! slb = Tix.Tree(f1, options='hlist.width 25')
! slb.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5)
!
! stext = Tix.ScrolledText(f2, name='stext')
font = root.tk.eval('tix option get fixed_font')
stext.text.config(font=font)
stext.text.bind('<Up>', lambda w=stext.text: w.yview(scroll='-1 unit'))
stext.text.bind('<Down>', lambda w=stext.text: w.yview(scroll='1 unit'))
stext.text.bind('<Left>', lambda w=stext.text: w.xview(scroll='-1 unit'))
stext.text.bind('<Right>', lambda w=stext.text: w.xview(scroll='1 unit'))
+ stext.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=7)
! frame = Tix.Frame(f2, name='frame')
! frame.pack(side=Tix.TOP, expand=0, fill=Tix.X, padx=7)
! run = Tix.Button(frame, text='Run ...', name='run')
! view = Tix.Button(frame, text='View Source ...', name='view')
! run.pack(side=Tix.LEFT, expand=0, fill=Tix.NONE)
! view.pack(side=Tix.LEFT, expand=0, fill=Tix.NONE)
stext.text['bg'] = slb.hlist['bg']
stext.text['state'] = 'disabled'
stext.text['wrap'] = 'none'
+ stext.text['width'] = 80
slb.hlist['separator'] = '.'
***************
*** 864,868 ****
--- 908,917 ----
slb.hlist['indent'] = 10
slb.hlist['wideselect'] = 1
+ slb.hlist['command'] = lambda args=0, w=w,slb=slb,stext=stext,run=run,view=view: Sample_Action(w, slb, stext, run, view, 'run')
+ slb.hlist['browsecmd'] = lambda args=0, w=w,slb=slb,stext=stext,run=run,view=view: Sample_Action(w, slb, stext, run, view, 'browse')
+ run['command'] = lambda args=0, w=w,slb=slb,stext=stext,run=run,view=view: Sample_Action(w, slb, stext, run, view, 'run')
+ view['command'] = lambda args=0, w=w,slb=slb,stext=stext,run=run,view=view: Sample_Action(w, slb, stext, run, view, 'view')
+
for type in ['widget', 'image']:
if type != 'widget':
***************
*** 880,889 ****
view['state'] = 'disabled'
! def Sample_Action(w, slb, action):
global demo
-
- run = w._nametowidget(str(w) + '.run')
- view = w._nametowidget(str(w) + '.view')
- stext = w._nametowidget(str(w) + '.stext')
hlist = slb.hlist
--- 929,934 ----
view['state'] = 'disabled'
! def Sample_Action(w, slb, stext, run, view, action):
global demo
hlist = slb.hlist