mirror of https://github.com/python/cpython
Sync tixwidgets from Mike Clarkson, a maintainer
This commit is contained in:
parent
f539bdeb9c
commit
ac30eadc0d
|
@ -6,14 +6,15 @@
|
||||||
#
|
#
|
||||||
# For Tix, see http://tix.sourceforge.net
|
# For Tix, see http://tix.sourceforge.net
|
||||||
#
|
#
|
||||||
# This is a demo program of all Tix widgets available from Python. If
|
# This is a demo program of some of the Tix widgets available in Python.
|
||||||
# you have installed Python & Tix properly, you can execute this as
|
# If you have installed Python & Tix properly, you can execute this as
|
||||||
#
|
#
|
||||||
# % python tixwidgets.py
|
# % python tixwidgets.py
|
||||||
#
|
#
|
||||||
|
|
||||||
import os, os.path, sys, Tix
|
import os, os.path, sys, Tix
|
||||||
from Tkconstants import *
|
from Tkconstants import *
|
||||||
|
import traceback, tkMessageBox
|
||||||
|
|
||||||
TCL_DONT_WAIT = 1<<1
|
TCL_DONT_WAIT = 1<<1
|
||||||
TCL_WINDOW_EVENTS = 1<<2
|
TCL_WINDOW_EVENTS = 1<<2
|
||||||
|
@ -65,10 +66,6 @@ class Demo:
|
||||||
hm = Tix.Menu(help, tearoff=0)
|
hm = Tix.Menu(help, tearoff=0)
|
||||||
help['menu'] = hm
|
help['menu'] = hm
|
||||||
|
|
||||||
if w.tk.eval ('info commands console') == "console":
|
|
||||||
fm.add_command(label='Console', underline=1,
|
|
||||||
command=lambda w=w: w.tk.eval('console show'))
|
|
||||||
|
|
||||||
fm.add_command(label='Exit', underline=1,
|
fm.add_command(label='Exit', underline=1,
|
||||||
command = lambda self=self: self.quitcmd () )
|
command = lambda self=self: self.quitcmd () )
|
||||||
hm.add_checkbutton(label='BalloonHelp', underline=0, command=ToggleHelp,
|
hm.add_checkbutton(label='BalloonHelp', underline=0, command=ToggleHelp,
|
||||||
|
@ -76,14 +73,15 @@ class Demo:
|
||||||
# The trace variable option doesn't seem to work, instead I use 'command'
|
# The trace variable option doesn't seem to work, instead I use 'command'
|
||||||
#apply(w.tk.call, ('trace', 'variable', self.useBalloons, 'w',
|
#apply(w.tk.call, ('trace', 'variable', self.useBalloons, 'w',
|
||||||
# ToggleHelp))
|
# ToggleHelp))
|
||||||
|
|
||||||
return w
|
return w
|
||||||
|
|
||||||
def MkMainNotebook(self):
|
def MkMainNotebook(self):
|
||||||
top = self.root
|
top = self.root
|
||||||
w = Tix.NoteBook(top, ipadx=5, ipady=5, options="""
|
w = Tix.NoteBook(top, ipadx=5, ipady=5, options="""
|
||||||
*TixNoteBook*tagPadX 6
|
tagPadX 6
|
||||||
*TixNoteBook*tagPadY 4
|
tagPadY 4
|
||||||
*TixNoteBook*borderWidth 2
|
borderWidth 2
|
||||||
""")
|
""")
|
||||||
# This may be required if there is no *Background option
|
# This may be required if there is no *Background option
|
||||||
top['bg'] = w['bg']
|
top['bg'] = w['bg']
|
||||||
|
@ -115,8 +113,10 @@ class Demo:
|
||||||
root = self.root
|
root = self.root
|
||||||
z = root.winfo_toplevel()
|
z = root.winfo_toplevel()
|
||||||
z.wm_title('Tix Widget Demonstration')
|
z.wm_title('Tix Widget Demonstration')
|
||||||
z.geometry('790x590+10+10')
|
if z.winfo_screenwidth() <= 800:
|
||||||
|
z.geometry('790x590+10+10')
|
||||||
|
else:
|
||||||
|
z.geometry('890x640+10+10')
|
||||||
demo.balloon = Tix.Balloon(root)
|
demo.balloon = Tix.Balloon(root)
|
||||||
frame1 = self.MkMainMenu()
|
frame1 = self.MkMainMenu()
|
||||||
frame2 = self.MkMainNotebook()
|
frame2 = self.MkMainNotebook()
|
||||||
|
@ -127,27 +127,39 @@ class Demo:
|
||||||
demo.balloon['statusbar'] = demo.statusbar
|
demo.balloon['statusbar'] = demo.statusbar
|
||||||
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
|
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
|
||||||
|
|
||||||
|
# To show Tcl errors - uncomment this to see the listbox bug.
|
||||||
|
# Tkinter defines a Tcl tkerror procedure that in effect
|
||||||
|
# silences all background Tcl error reporting.
|
||||||
|
# root.tk.eval('if {[info commands tkerror] != ""} {rename tkerror pytkerror}')
|
||||||
def quitcmd (self):
|
def quitcmd (self):
|
||||||
"""Quit our mainloop. It is up to you to call root.destroy() after."""
|
"""Quit our mainloop. It is up to you to call root.destroy() after."""
|
||||||
self.exit = 0
|
self.exit = 0
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
import tkMessageBox, traceback
|
"""This is an explict replacement for _tkinter mainloop()
|
||||||
|
It lets you catch keyboard interrupts easier, and avoids
|
||||||
|
the 20 msec. dead sleep() which burns a constant CPU."""
|
||||||
while self.exit < 0:
|
while self.exit < 0:
|
||||||
|
# There are 2 whiles here. The outer one lets you continue
|
||||||
|
# after a ^C interrupt.
|
||||||
try:
|
try:
|
||||||
self.root.tk.dooneevent(TCL_ALL_EVENTS)
|
# This is the replacement for _tkinter mainloop()
|
||||||
|
# It blocks waiting for the next Tcl event using select.
|
||||||
|
while self.exit < 0:
|
||||||
|
self.root.tk.dooneevent(TCL_ALL_EVENTS)
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
# Tkinter uses SystemExit to exit
|
||||||
#print 'Exit'
|
#print 'Exit'
|
||||||
self.exit = 1
|
self.exit = 1
|
||||||
break
|
return
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
if tkMessageBox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
|
if tkMessageBox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
|
||||||
# self.tk.eval('exit')
|
# self.tk.eval('exit')
|
||||||
|
self.exit = 1
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
pass
|
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
|
# Otherwise it's some other error - be nice and say why
|
||||||
t, v, tb = sys.exc_info()
|
t, v, tb = sys.exc_info()
|
||||||
text = ""
|
text = ""
|
||||||
for line in traceback.format_exception(t,v,tb):
|
for line in traceback.format_exception(t,v,tb):
|
||||||
|
@ -254,19 +266,16 @@ def ToggleHelp():
|
||||||
|
|
||||||
def MkChoosers(nb, name):
|
def MkChoosers(nb, name):
|
||||||
w = nb.page(name)
|
w = nb.page(name)
|
||||||
prefix = Tix.OptionName(w)
|
options = "label.padX 4"
|
||||||
if not prefix:
|
|
||||||
prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixLabelFrame*label.padX', 4)
|
|
||||||
|
|
||||||
til = Tix.LabelFrame(w, label='Chooser Widgets')
|
til = Tix.LabelFrame(w, label='Chooser Widgets', options=options)
|
||||||
cbx = Tix.LabelFrame(w, label='tixComboBox')
|
cbx = Tix.LabelFrame(w, label='tixComboBox', options=options)
|
||||||
ctl = Tix.LabelFrame(w, label='tixControl')
|
ctl = Tix.LabelFrame(w, label='tixControl', options=options)
|
||||||
sel = Tix.LabelFrame(w, label='tixSelect')
|
sel = Tix.LabelFrame(w, label='tixSelect', options=options)
|
||||||
opt = Tix.LabelFrame(w, label='tixOptionMenu')
|
opt = Tix.LabelFrame(w, label='tixOptionMenu', options=options)
|
||||||
fil = Tix.LabelFrame(w, label='tixFileEntry')
|
fil = Tix.LabelFrame(w, label='tixFileEntry', options=options)
|
||||||
fbx = Tix.LabelFrame(w, label='tixFileSelectBox')
|
fbx = Tix.LabelFrame(w, label='tixFileSelectBox', options=options)
|
||||||
tbr = Tix.LabelFrame(w, label='Tool Bar')
|
tbr = Tix.LabelFrame(w, label='Tool Bar', options=options)
|
||||||
|
|
||||||
MkTitle(til.frame)
|
MkTitle(til.frame)
|
||||||
MkCombo(cbx.frame)
|
MkCombo(cbx.frame)
|
||||||
|
@ -293,16 +302,12 @@ def MkChoosers(nb, name):
|
||||||
fbx.form(right=-1, top=0, left='%66')
|
fbx.form(right=-1, top=0, left='%66')
|
||||||
|
|
||||||
def MkCombo(w):
|
def MkCombo(w):
|
||||||
prefix = Tix.OptionName(w)
|
options="label.width %d label.anchor %s entry.width %d" % (10, Tix.E, 14)
|
||||||
if not prefix: prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixComboBox*label.width', 10)
|
|
||||||
w.option_add('*' + prefix + '*TixComboBox*label.anchor', Tix.E)
|
|
||||||
w.option_add('*' + prefix + '*TixComboBox*entry.width', 14)
|
|
||||||
|
|
||||||
static = Tix.ComboBox(w, label='Static', editable=0)
|
static = Tix.ComboBox(w, label='Static', editable=0, options=options)
|
||||||
editable = Tix.ComboBox(w, label='Editable', editable=1)
|
editable = Tix.ComboBox(w, label='Editable', editable=1, options=options)
|
||||||
history = Tix.ComboBox(w, label='History', editable=1, history=1,
|
history = Tix.ComboBox(w, label='History', editable=1, history=1,
|
||||||
anchor=Tix.E)
|
anchor=Tix.E, options=options)
|
||||||
static.insert(Tix.END, 'January')
|
static.insert(Tix.END, 'January')
|
||||||
static.insert(Tix.END, 'February')
|
static.insert(Tix.END, 'February')
|
||||||
static.insert(Tix.END, 'March')
|
static.insert(Tix.END, 'March')
|
||||||
|
@ -355,16 +360,13 @@ def spin_validate(w):
|
||||||
def MkControl(w):
|
def MkControl(w):
|
||||||
global demo_spintxt
|
global demo_spintxt
|
||||||
|
|
||||||
prefix = Tix.OptionName(w)
|
options="label.width %d label.anchor %s entry.width %d" % (10, Tix.E, 13)
|
||||||
if not prefix: prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixControl*label.width', 10)
|
|
||||||
w.option_add('*' + prefix + '*TixControl*label.anchor', Tix.E)
|
|
||||||
w.option_add('*' + prefix + '*TixControl*entry.width', 13)
|
|
||||||
|
|
||||||
demo_spintxt = Tix.StringVar()
|
demo_spintxt = Tix.StringVar()
|
||||||
demo_spintxt.set(states[0])
|
demo_spintxt.set(states[0])
|
||||||
simple = Tix.Control(w, label='Numbers')
|
simple = Tix.Control(w, label='Numbers', options=options)
|
||||||
spintxt = Tix.Control(w, label='States', variable=demo_spintxt)
|
spintxt = Tix.Control(w, label='States', variable=demo_spintxt,
|
||||||
|
options=options)
|
||||||
spintxt['incrcmd'] = lambda w=spintxt: spin_cmd(w, 1)
|
spintxt['incrcmd'] = lambda w=spintxt: spin_cmd(w, 1)
|
||||||
spintxt['decrcmd'] = lambda w=spintxt: spin_cmd(w, -1)
|
spintxt['decrcmd'] = lambda w=spintxt: spin_cmd(w, -1)
|
||||||
spintxt['validatecmd'] = lambda w=spintxt: spin_validate(w)
|
spintxt['validatecmd'] = lambda w=spintxt: spin_validate(w)
|
||||||
|
@ -373,14 +375,16 @@ def MkControl(w):
|
||||||
spintxt.pack(side=Tix.TOP, padx=5, pady=3)
|
spintxt.pack(side=Tix.TOP, padx=5, pady=3)
|
||||||
|
|
||||||
def MkSelect(w):
|
def MkSelect(w):
|
||||||
prefix = Tix.OptionName(w)
|
options = "label.anchor %s" % Tix.CENTER
|
||||||
if not prefix: prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixSelect*label.anchor', Tix.CENTER)
|
|
||||||
w.option_add('*' + prefix + '*TixSelect*orientation', Tix.VERTICAL)
|
|
||||||
w.option_add('*' + prefix + '*TixSelect*labelSide', Tix.TOP)
|
|
||||||
|
|
||||||
sel1 = Tix.Select(w, label='Mere Mortals', allowzero=1, radio=1)
|
sel1 = Tix.Select(w, label='Mere Mortals', allowzero=1, radio=1,
|
||||||
sel2 = Tix.Select(w, label='Geeks', allowzero=1, radio=0)
|
orientation=Tix.VERTICAL,
|
||||||
|
labelside=Tix.TOP,
|
||||||
|
options=options)
|
||||||
|
sel2 = Tix.Select(w, label='Geeks', allowzero=1, radio=0,
|
||||||
|
orientation=Tix.VERTICAL,
|
||||||
|
labelside= Tix.TOP,
|
||||||
|
options=options)
|
||||||
|
|
||||||
sel1.add('eat', text='Eat')
|
sel1.add('eat', text='Eat')
|
||||||
sel1.add('work', text='Work')
|
sel1.add('work', text='Work')
|
||||||
|
@ -398,10 +402,9 @@ def MkSelect(w):
|
||||||
sel2.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
|
sel2.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
|
||||||
|
|
||||||
def MkOptMenu(w):
|
def MkOptMenu(w):
|
||||||
prefix = Tix.OptionName(w)
|
options='menubutton.width 15 label.anchor %s' % Tix.E
|
||||||
if not prefix: prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixOptionMenu*label.anchor', Tix.E)
|
m = Tix.OptionMenu(w, label='File Format : ', options=options)
|
||||||
m = Tix.OptionMenu(w, label='File Format : ', options='menubutton.width 15')
|
|
||||||
m.add_command('text', label='Plain Text')
|
m.add_command('text', label='Plain Text')
|
||||||
m.add_command('post', label='PostScript')
|
m.add_command('post', label='PostScript')
|
||||||
m.add_command('format', label='Formatted Text')
|
m.add_command('format', label='Formatted Text')
|
||||||
|
@ -433,17 +436,18 @@ def MkFileBox(w):
|
||||||
box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
|
box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
|
||||||
|
|
||||||
def MkToolBar(w):
|
def MkToolBar(w):
|
||||||
|
"""The Select widget is also good for arranging buttons in a tool bar.
|
||||||
|
"""
|
||||||
global demo
|
global demo
|
||||||
|
|
||||||
prefix = Tix.OptionName(w)
|
options='frame.borderWidth 1'
|
||||||
if not prefix: prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixSelect*frame.borderWidth', 1)
|
|
||||||
msg = Tix.Message(w,
|
msg = Tix.Message(w,
|
||||||
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
||||||
text='The Select widget is also good for arranging buttons in a tool bar.')
|
text='The Select widget is also good for arranging buttons in a tool bar.')
|
||||||
bar = Tix.Frame(w, bd=2, relief=Tix.RAISED)
|
bar = Tix.Frame(w, bd=2, relief=Tix.RAISED)
|
||||||
font = Tix.Select(w, allowzero=1, radio=0, label='')
|
font = Tix.Select(w, allowzero=1, radio=0, label='', options=options)
|
||||||
para = Tix.Select(w, allowzero=0, radio=1, label='')
|
para = Tix.Select(w, allowzero=0, radio=1, label='', options=options)
|
||||||
|
|
||||||
font.add('bold', bitmap='@' + demo.dir + '/bitmaps/bold.xbm')
|
font.add('bold', bitmap='@' + demo.dir + '/bitmaps/bold.xbm')
|
||||||
font.add('italic', bitmap='@' + demo.dir + '/bitmaps/italic.xbm')
|
font.add('italic', bitmap='@' + demo.dir + '/bitmaps/italic.xbm')
|
||||||
|
@ -461,9 +465,6 @@ def MkToolBar(w):
|
||||||
para.pack({'in':bar}, side=Tix.LEFT, padx=3, pady=3)
|
para.pack({'in':bar}, side=Tix.LEFT, padx=3, pady=3)
|
||||||
|
|
||||||
def MkTitle(w):
|
def MkTitle(w):
|
||||||
prefix = Tix.OptionName(w)
|
|
||||||
if not prefix: prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixSelect*frame.borderWidth', 1)
|
|
||||||
msg = Tix.Message(w,
|
msg = Tix.Message(w,
|
||||||
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
||||||
text='There are many types of "chooser" widgets that allow the user to input different types of information')
|
text='There are many types of "chooser" widgets that allow the user to input different types of information')
|
||||||
|
@ -471,14 +472,11 @@ def MkTitle(w):
|
||||||
|
|
||||||
def MkScroll(nb, name):
|
def MkScroll(nb, name):
|
||||||
w = nb.page(name)
|
w = nb.page(name)
|
||||||
prefix = Tix.OptionName(w)
|
options='label.padX 4'
|
||||||
if not prefix:
|
|
||||||
prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixLabelFrame*label.padX', 4)
|
|
||||||
|
|
||||||
sls = Tix.LabelFrame(w, label='tixScrolledListBox')
|
sls = Tix.LabelFrame(w, label='tixScrolledListBox', options=options)
|
||||||
swn = Tix.LabelFrame(w, label='tixScrolledWindow')
|
swn = Tix.LabelFrame(w, label='tixScrolledWindow', options=options)
|
||||||
stx = Tix.LabelFrame(w, label='tixScrolledText')
|
stx = Tix.LabelFrame(w, label='tixScrolledText', options=options)
|
||||||
|
|
||||||
MkSList(sls.frame)
|
MkSList(sls.frame)
|
||||||
MkSWindow(swn.frame)
|
MkSWindow(swn.frame)
|
||||||
|
@ -488,7 +486,11 @@ def MkScroll(nb, name):
|
||||||
swn.form(top=0, left=sls, right='%66', bottom=-1)
|
swn.form(top=0, left=sls, right='%66', bottom=-1)
|
||||||
stx.form(top=0, left=swn, right=-1, bottom=-1)
|
stx.form(top=0, left=swn, right=-1, bottom=-1)
|
||||||
|
|
||||||
|
|
||||||
def MkSList(w):
|
def MkSList(w):
|
||||||
|
"""This TixScrolledListBox is configured so that it uses scrollbars
|
||||||
|
only when it is necessary. Use the handles to resize the listbox and
|
||||||
|
watch the scrollbars automatically appear and disappear. """
|
||||||
top = Tix.Frame(w, width=300, height=330)
|
top = Tix.Frame(w, width=300, height=330)
|
||||||
bot = Tix.Frame(w)
|
bot = Tix.Frame(w)
|
||||||
msg = Tix.Message(top,
|
msg = Tix.Message(top,
|
||||||
|
@ -522,13 +524,13 @@ def SList_reset(rh, list):
|
||||||
list.update()
|
list.update()
|
||||||
rh.attach_widget(list)
|
rh.attach_widget(list)
|
||||||
|
|
||||||
# See below why this is necessary.
|
|
||||||
global image1
|
|
||||||
image1 = None
|
|
||||||
def MkSWindow(w):
|
def MkSWindow(w):
|
||||||
global demo, image1
|
"""The ScrolledWindow widget allows you to scroll any kind of Tk
|
||||||
|
widget. It is more versatile than a scrolled canvas widget.
|
||||||
|
"""
|
||||||
|
global demo
|
||||||
|
|
||||||
text = 'The TixScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.'
|
text = 'The Tix ScrolledWindow 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')
|
file = os.path.join(demo.dir, 'bitmaps', 'tix.gif')
|
||||||
if not os.path.isfile(file):
|
if not os.path.isfile(file):
|
||||||
|
@ -542,10 +544,10 @@ def MkSWindow(w):
|
||||||
|
|
||||||
win = Tix.ScrolledWindow(top, scrollbar='auto')
|
win = Tix.ScrolledWindow(top, scrollbar='auto')
|
||||||
|
|
||||||
# This image is not showing up under Python unless it is set to a
|
global image1
|
||||||
# global variable - no problem under Tcl. I assume it is being garbage
|
# This image is not showing up in the Label unless it is set to a
|
||||||
# collected some how, even though the tcl command 'image names' shows
|
# global variable - no problem under Tcl/Tix. It is being
|
||||||
# that as far as Tcl is concerned, the image exists and is called pyimage1.
|
# garbage collected at the end of this proecedure if not global
|
||||||
image1 = Tix.Image('photo', file=file)
|
image1 = Tix.Image('photo', file=file)
|
||||||
lbl = Tix.Label(win.window, image=image1)
|
lbl = Tix.Label(win.window, image=image1)
|
||||||
lbl.pack(expand=1, fill=Tix.BOTH)
|
lbl.pack(expand=1, fill=Tix.BOTH)
|
||||||
|
@ -561,8 +563,6 @@ def MkSWindow(w):
|
||||||
btn.pack(anchor=Tix.CENTER)
|
btn.pack(anchor=Tix.CENTER)
|
||||||
top.pack(expand=1, fill=Tix.BOTH)
|
top.pack(expand=1, fill=Tix.BOTH)
|
||||||
bot.pack(fill=Tix.BOTH)
|
bot.pack(fill=Tix.BOTH)
|
||||||
win.bind('<Map>', func=lambda arg=0, rh=rh, win=win:
|
|
||||||
win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
|
|
||||||
|
|
||||||
def SWindow_reset(rh, win):
|
def SWindow_reset(rh, win):
|
||||||
win.place(x=30, y=150, width=190, height=120)
|
win.place(x=30, y=150, width=190, height=120)
|
||||||
|
@ -570,11 +570,13 @@ def SWindow_reset(rh, win):
|
||||||
rh.attach_widget(win)
|
rh.attach_widget(win)
|
||||||
|
|
||||||
def MkSText(w):
|
def MkSText(w):
|
||||||
|
"""The TixScrolledWindow widget allows you to scroll any kind of Tk
|
||||||
|
widget. It is more versatile than a scrolled canvas widget."""
|
||||||
top = Tix.Frame(w, width=330, height=330)
|
top = Tix.Frame(w, width=330, height=330)
|
||||||
bot = Tix.Frame(w)
|
bot = Tix.Frame(w)
|
||||||
msg = Tix.Message(top,
|
msg = Tix.Message(top,
|
||||||
relief=Tix.FLAT, width=200, anchor=Tix.N,
|
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.')
|
text='The Tix ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.')
|
||||||
|
|
||||||
win = Tix.ScrolledText(top, scrollbar='auto')
|
win = Tix.ScrolledText(top, scrollbar='auto')
|
||||||
# win.text['wrap'] = 'none'
|
# win.text['wrap'] = 'none'
|
||||||
|
@ -600,13 +602,10 @@ def SText_reset(rh, win):
|
||||||
|
|
||||||
def MkManager(nb, name):
|
def MkManager(nb, name):
|
||||||
w = nb.page(name)
|
w = nb.page(name)
|
||||||
prefix = Tix.OptionName(w)
|
options='label.padX 4'
|
||||||
if not prefix:
|
|
||||||
prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixLabelFrame*label.padX', 4)
|
|
||||||
|
|
||||||
pane = Tix.LabelFrame(w, label='tixPanedWindow')
|
pane = Tix.LabelFrame(w, label='tixPanedWindow', options=options)
|
||||||
note = Tix.LabelFrame(w, label='tixNoteBook')
|
note = Tix.LabelFrame(w, label='tixNoteBook', options=options)
|
||||||
|
|
||||||
MkPanedWindow(pane.frame)
|
MkPanedWindow(pane.frame)
|
||||||
MkNoteBook(note.frame)
|
MkNoteBook(note.frame)
|
||||||
|
@ -615,6 +614,10 @@ def MkManager(nb, name):
|
||||||
note.form(top=0, right=-1, bottom=-1)
|
note.form(top=0, right=-1, bottom=-1)
|
||||||
|
|
||||||
def MkPanedWindow(w):
|
def MkPanedWindow(w):
|
||||||
|
"""The PanedWindow widget allows the user to interactively manipulate
|
||||||
|
the sizes of several panes. The panes can be arranged either vertically
|
||||||
|
or horizontally.
|
||||||
|
"""
|
||||||
msg = Tix.Message(w,
|
msg = Tix.Message(w,
|
||||||
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
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.')
|
text='The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.')
|
||||||
|
@ -661,15 +664,12 @@ def MkNoteBook(w):
|
||||||
msg = Tix.Message(w,
|
msg = Tix.Message(w,
|
||||||
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
||||||
text='The NoteBook widget allows you to layout a complex interface into individual pages.')
|
text='The NoteBook widget allows you to layout a complex interface into individual pages.')
|
||||||
prefix = Tix.OptionName(w)
|
# prefix = Tix.OptionName(w)
|
||||||
if not prefix:
|
# if not prefix: prefix = ''
|
||||||
prefix = ''
|
# w.option_add('*' + prefix + '*TixNoteBook*tagPadX', 8)
|
||||||
w.option_add('*' + prefix + '*TixControl*entry.width', 10)
|
options = "entry.width %d label.width %d label.anchor %s" % (10, 18, Tix.E)
|
||||||
w.option_add('*' + prefix + '*TixControl*label.width', 18)
|
|
||||||
w.option_add('*' + prefix + '*TixControl*label.anchor', Tix.E)
|
|
||||||
w.option_add('*' + prefix + '*TixNoteBook*tagPadX', 8)
|
|
||||||
|
|
||||||
nb = Tix.NoteBook(w, ipadx=6, ipady=6)
|
nb = Tix.NoteBook(w, ipadx=6, ipady=6, options=options)
|
||||||
nb.add('hard_disk', label="Hard Disk", underline=0)
|
nb.add('hard_disk', label="Hard Disk", underline=0)
|
||||||
nb.add('network', label="Network", underline=0)
|
nb.add('network', label="Network", underline=0)
|
||||||
|
|
||||||
|
@ -714,30 +714,33 @@ def CreateCommonButtons(f):
|
||||||
|
|
||||||
def MkDirList(nb, name):
|
def MkDirList(nb, name):
|
||||||
w = nb.page(name)
|
w = nb.page(name)
|
||||||
prefix = Tix.OptionName(w)
|
options = "label.padX 4"
|
||||||
if not prefix:
|
|
||||||
prefix = ''
|
|
||||||
w.option_add('*' + prefix + '*TixLabelFrame*label.padX', 4)
|
|
||||||
|
|
||||||
dir = Tix.LabelFrame(w, label='tixDirList')
|
dir = Tix.LabelFrame(w, label='tixDirList', options=options)
|
||||||
fsbox = Tix.LabelFrame(w, label='tixExFileSelectBox')
|
fsbox = Tix.LabelFrame(w, label='tixExFileSelectBox', options=options)
|
||||||
MkDirListWidget(dir.frame)
|
MkDirListWidget(dir.frame)
|
||||||
MkExFileWidget(fsbox.frame)
|
MkExFileWidget(fsbox.frame)
|
||||||
dir.form(top=0, left=0, right='%40', bottom=-1)
|
dir.form(top=0, left=0, right='%40', bottom=-1)
|
||||||
fsbox.form(top=0, left='%40', right=-1, bottom=-1)
|
fsbox.form(top=0, left='%40', right=-1, bottom=-1)
|
||||||
|
|
||||||
def MkDirListWidget(w):
|
def MkDirListWidget(w):
|
||||||
|
"""The TixDirList widget gives a graphical representation of the file
|
||||||
|
system directory and makes it easy for the user to choose and access
|
||||||
|
directories.
|
||||||
|
"""
|
||||||
msg = Tix.Message(w,
|
msg = Tix.Message(w,
|
||||||
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
||||||
text='The TixDirList widget gives a graphical representation of the file system directory and makes it easy for the user to choose and access directories.')
|
text='The Tix DirList widget gives a graphical representation of the file system directory and makes it easy for the user to choose and access directories.')
|
||||||
dirlist = Tix.DirList(w, options='hlist.padY 1 hlist.width 25 hlist.height 16')
|
dirlist = Tix.DirList(w, options='hlist.padY 1 hlist.width 25 hlist.height 16')
|
||||||
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
|
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
|
||||||
dirlist.pack(side=Tix.TOP, padx=3, pady=3)
|
dirlist.pack(side=Tix.TOP, padx=3, pady=3)
|
||||||
|
|
||||||
def MkExFileWidget(w):
|
def MkExFileWidget(w):
|
||||||
|
"""The TixExFileSelectBox widget is more user friendly than the Motif
|
||||||
|
style FileSelectBox. """
|
||||||
msg = Tix.Message(w,
|
msg = Tix.Message(w,
|
||||||
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
relief=Tix.FLAT, width=240, anchor=Tix.N,
|
||||||
text='The TixExFileSelectBox widget is more user friendly than the Motif style FileSelectBox.')
|
text='The Tix ExFileSelectBox widget is more user friendly than the Motif style FileSelectBox.')
|
||||||
# There's a bug in the ComboBoxes - the scrolledlistbox is destroyed
|
# There's a bug in the ComboBoxes - the scrolledlistbox is destroyed
|
||||||
box = Tix.ExFileSelectBox(w, bd=2, relief=Tix.RAISED)
|
box = Tix.ExFileSelectBox(w, bd=2, relief=Tix.RAISED)
|
||||||
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
|
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
|
||||||
|
@ -780,7 +783,7 @@ samples = {'Balloon' : 'Balloon',
|
||||||
## }
|
## }
|
||||||
##
|
##
|
||||||
## set cmpimg {
|
## set cmpimg {
|
||||||
## {f "In Buttons" CmpImg.tcl }
|
##done {f "In Buttons" CmpImg.tcl }
|
||||||
## {f "In NoteBook" CmpImg2.tcl }
|
## {f "In NoteBook" CmpImg2.tcl }
|
||||||
## {f "Notebook Color Tabs" CmpImg4.tcl }
|
## {f "Notebook Color Tabs" CmpImg4.tcl }
|
||||||
## {f "Icons" CmpImg3.tcl }
|
## {f "Icons" CmpImg3.tcl }
|
||||||
|
@ -833,7 +836,7 @@ samples = {'Balloon' : 'Balloon',
|
||||||
## }
|
## }
|
||||||
##
|
##
|
||||||
## set manager {
|
## set manager {
|
||||||
##na {f ListNoteBook ListNBK.tcl }
|
## {f ListNoteBook ListNBK.tcl }
|
||||||
##done {f NoteBook NoteBook.tcl }
|
##done {f NoteBook NoteBook.tcl }
|
||||||
##done {f PanedWindow PanedWin.tcl }
|
##done {f PanedWindow PanedWin.tcl }
|
||||||
## }
|
## }
|
||||||
|
@ -845,7 +848,7 @@ samples = {'Balloon' : 'Balloon',
|
||||||
##done {f Control Control.tcl }
|
##done {f Control Control.tcl }
|
||||||
## {f LabelEntry LabEntry.tcl }
|
## {f LabelEntry LabEntry.tcl }
|
||||||
## {f LabelFrame LabFrame.tcl }
|
## {f LabelFrame LabFrame.tcl }
|
||||||
##na {f Meter Meter.tcl {c tixMeter}}
|
## {f Meter Meter.tcl {c tixMeter}}
|
||||||
##done {f OptionMenu OptMenu.tcl }
|
##done {f OptionMenu OptMenu.tcl }
|
||||||
##done {f PopupMenu PopMenu.tcl }
|
##done {f PopupMenu PopMenu.tcl }
|
||||||
## {f Select Select.tcl }
|
## {f Select Select.tcl }
|
||||||
|
@ -862,12 +865,7 @@ stypes['image'] = ['Compound Image']
|
||||||
|
|
||||||
def MkSample(nb, name):
|
def MkSample(nb, name):
|
||||||
w = nb.page(name)
|
w = nb.page(name)
|
||||||
prefix = Tix.OptionName(w)
|
options = "label.padX 4"
|
||||||
if not prefix:
|
|
||||||
prefix = ''
|
|
||||||
else:
|
|
||||||
prefix = '*' + prefix
|
|
||||||
w.option_add(prefix + '*TixLabelFrame*label.padX', 4)
|
|
||||||
|
|
||||||
pane = Tix.PanedWindow(w, orientation='horizontal')
|
pane = Tix.PanedWindow(w, orientation='horizontal')
|
||||||
pane.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH)
|
pane.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH)
|
||||||
|
@ -876,25 +874,19 @@ def MkSample(nb, name):
|
||||||
f1['relief'] = 'flat'
|
f1['relief'] = 'flat'
|
||||||
f2['relief'] = 'flat'
|
f2['relief'] = 'flat'
|
||||||
|
|
||||||
lab = Tix.Label(f1, text='Select a sample program:', anchor=Tix.W)
|
lab = Tix.LabelFrame(f1, label='Select a sample program:')
|
||||||
lab.pack(side=Tix.TOP, expand=0, fill=Tix.X, padx=5, pady=5)
|
lab.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5, pady=5)
|
||||||
lab1 = Tix.Label(f2, text='Source:', anchor=Tix.W)
|
lab1 = Tix.LabelFrame(f2, label='Source:')
|
||||||
lab1.pack(side=Tix.TOP, expand=0, fill=Tix.X, padx=5, pady=5)
|
lab1.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5, pady=5)
|
||||||
|
|
||||||
slb = Tix.Tree(f1, options='hlist.width 25')
|
slb = Tix.Tree(lab.frame, options='hlist.width 20')
|
||||||
slb.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5)
|
slb.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5)
|
||||||
|
|
||||||
stext = Tix.ScrolledText(f2, name='stext')
|
stext = Tix.ScrolledText(lab1.frame, name='stext')
|
||||||
font = root.tk.eval('tix option get fixed_font')
|
font = root.tk.eval('tix option get fixed_font')
|
||||||
stext.text.config(font=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 = Tix.Frame(lab1.frame, name='frame')
|
||||||
frame.pack(side=Tix.TOP, expand=0, fill=Tix.X, padx=7)
|
|
||||||
|
|
||||||
run = Tix.Button(frame, text='Run ...', name='run')
|
run = Tix.Button(frame, text='Run ...', name='run')
|
||||||
view = Tix.Button(frame, text='View Source ...', name='view')
|
view = Tix.Button(frame, text='View Source ...', name='view')
|
||||||
|
@ -906,6 +898,9 @@ def MkSample(nb, name):
|
||||||
stext.text['wrap'] = 'none'
|
stext.text['wrap'] = 'none'
|
||||||
stext.text['width'] = 80
|
stext.text['width'] = 80
|
||||||
|
|
||||||
|
frame.pack(side=Tix.BOTTOM, expand=0, fill=Tix.X, padx=7)
|
||||||
|
stext.pack(side=Tix.TOP, expand=0, fill=Tix.BOTH, padx=7)
|
||||||
|
|
||||||
slb.hlist['separator'] = '.'
|
slb.hlist['separator'] = '.'
|
||||||
slb.hlist['width'] = 25
|
slb.hlist['width'] = 25
|
||||||
slb.hlist['drawbranch'] = 0
|
slb.hlist['drawbranch'] = 0
|
||||||
|
|
Loading…
Reference in New Issue