mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
Patch #485959: Various changes to Tix demos.
This commit is contained in:
parent
42ab61eeab
commit
8ec03e0528
14 changed files with 407 additions and 308 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
@ -17,29 +17,52 @@
|
||||||
|
|
||||||
import Tix
|
import Tix
|
||||||
|
|
||||||
def RunSample(w):
|
TCL_ALL_EVENTS = 0
|
||||||
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
|
def RunSample (root):
|
||||||
button1 = Tix.Button(w, text='Something Unexpected',
|
balloon = DemoBalloon(root)
|
||||||
command=lambda w=w: w.destroy())
|
balloon.mainloop()
|
||||||
button2 = Tix.Button(w, text='Something Else Unexpected')
|
balloon.destroy()
|
||||||
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
|
class DemoBalloon:
|
||||||
# to provide tips for:
|
def __init__(self, w):
|
||||||
b = Tix.Balloon(w, statusbar=status)
|
self.root = w
|
||||||
|
self.exit = -1
|
||||||
|
|
||||||
b.bind_widget(button1, balloonmsg='Close Window',
|
z = w.winfo_toplevel()
|
||||||
statusmsg='Press this button to close this window')
|
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
|
||||||
b.bind_widget(button2, balloonmsg='Self-destruct button',
|
|
||||||
statusmsg='Press this button and it will destroy itself')
|
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__':
|
if __name__ == '__main__':
|
||||||
root = Tix.Tk()
|
root = Tix.Tk()
|
||||||
|
|
||||||
RunSample(root)
|
RunSample(root)
|
||||||
root.mainloop()
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
@ -85,13 +85,15 @@ def RunSample(w):
|
||||||
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
|
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
|
||||||
|
|
||||||
def select_month(event=None):
|
def select_month(event=None):
|
||||||
print "Month =", demo_month.get()
|
# tixDemo:Status "Month = %s" % demo_month.get()
|
||||||
|
pass
|
||||||
|
|
||||||
def select_year(event=None):
|
def select_year(event=None):
|
||||||
print "Year =", demo_year.get()
|
# tixDemo:Status "Year = %s" % demo_year.get()
|
||||||
|
pass
|
||||||
|
|
||||||
def ok_command(w):
|
def ok_command(w):
|
||||||
print "Month =", demo_month.get(), ", Year=", demo_year.get()
|
# tixDemo:Status "Month = %s, Year= %s" % (demo_month.get(), demo_year.get())
|
||||||
w.destroy()
|
w.destroy()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
@ -17,57 +17,82 @@
|
||||||
# This example program uses three Control widgets. One lets you select
|
# This example program uses three Control widgets. One lets you select
|
||||||
# integer values; one lets you select floating point values and the last
|
# integer values; one lets you select floating point values and the last
|
||||||
# one lets you select a few names.
|
# one lets you select a few names.
|
||||||
#
|
|
||||||
import Tix
|
import Tix
|
||||||
|
|
||||||
def RunSample(w):
|
TCL_ALL_EVENTS = 0
|
||||||
global demo_maker, demo_thrust, demo_num_engines
|
|
||||||
|
|
||||||
demo_maker = Tix.StringVar()
|
def RunSample (root):
|
||||||
demo_thrust = Tix.DoubleVar()
|
control = DemoControl(root)
|
||||||
demo_num_engines = Tix.IntVar()
|
control.mainloop()
|
||||||
demo_maker.set('P&W')
|
control.destroy()
|
||||||
demo_thrust.set(20000.0)
|
|
||||||
demo_num_engines.set(2)
|
|
||||||
|
|
||||||
top = Tix.Frame(w, bd=1, relief=Tix.RAISED)
|
class DemoControl:
|
||||||
|
def __init__(self, w):
|
||||||
|
self.root = w
|
||||||
|
self.exit = -1
|
||||||
|
|
||||||
# $w.top.a allows only integer values
|
global demo_maker, demo_thrust, demo_num_engines
|
||||||
#
|
|
||||||
# [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',
|
demo_maker = Tix.StringVar()
|
||||||
variable=demo_maker,
|
demo_thrust = Tix.DoubleVar()
|
||||||
options='entry.width 10 label.width 20 label.anchor e')
|
demo_num_engines = Tix.IntVar()
|
||||||
|
demo_maker.set('P&W')
|
||||||
|
demo_thrust.set(20000.0)
|
||||||
|
demo_num_engines.set(2)
|
||||||
|
|
||||||
# We can't define these in the init because the widget 'c' doesn't
|
top = Tix.Frame(w, bd=1, relief=Tix.RAISED)
|
||||||
# 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)
|
# $w.top.a allows only integer values
|
||||||
b.pack(side=Tix.TOP, anchor=Tix.W)
|
#
|
||||||
c.pack(side=Tix.TOP, anchor=Tix.W)
|
# [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')
|
||||||
|
|
||||||
box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
|
b = Tix.Control(top, label='Thrust: ', integer=0,
|
||||||
box.add('ok', text='Ok', underline=0, width=6,
|
min='10000.0', max='60000.0', step=500,
|
||||||
command=lambda w=w: ok_command(w))
|
variable=demo_thrust,
|
||||||
box.add('cancel', text='Cancel', underline=0, width=6,
|
options='entry.width 10 label.width 20 label.anchor e')
|
||||||
command=lambda w=w: w.destroy())
|
|
||||||
box.pack(side=Tix.BOTTOM, fill=Tix.X)
|
c = Tix.Control(top, label='Engine Maker: ', value='P&W',
|
||||||
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
|
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']
|
maker_list = ['P&W', 'GE', 'Rolls Royce']
|
||||||
|
|
||||||
|
|
@ -92,11 +117,6 @@ def validate_maker(w):
|
||||||
# Works here though. Why ? Beats me.
|
# Works here though. Why ? Beats me.
|
||||||
return maker_list[i]
|
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__':
|
if __name__ == '__main__':
|
||||||
root = Tix.Tk()
|
root = Tix.Tk()
|
||||||
RunSample(root)
|
RunSample(root)
|
||||||
root.mainloop()
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program using tixwish.
|
# program using tixwish.
|
||||||
|
|
@ -19,15 +19,9 @@
|
||||||
import Tix, os, copy
|
import Tix, os, copy
|
||||||
from Tkconstants import *
|
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
|
TCL_ALL_EVENTS = 0
|
||||||
|
|
||||||
def RunSample (root):
|
def RunSample (root):
|
||||||
global dirlist
|
|
||||||
dirlist = DemoDirList(root)
|
dirlist = DemoDirList(root)
|
||||||
dirlist.mainloop()
|
dirlist.mainloop()
|
||||||
dirlist.destroy()
|
dirlist.destroy()
|
||||||
|
|
@ -38,7 +32,7 @@ class DemoDirList:
|
||||||
self.exit = -1
|
self.exit = -1
|
||||||
|
|
||||||
z = w.winfo_toplevel()
|
z = w.winfo_toplevel()
|
||||||
z.wm_title('Tix.DirList Widget Demo')
|
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
|
||||||
|
|
||||||
# Create the tixDirList and the tixLabelEntry widgets on the on the top
|
# Create the tixDirList and the tixLabelEntry widgets on the on the top
|
||||||
# of the dialog box
|
# of the dialog box
|
||||||
|
|
@ -98,7 +92,6 @@ class DemoDirList:
|
||||||
command = lambda self=self: self.quitcmd () )
|
command = lambda self=self: self.quitcmd () )
|
||||||
|
|
||||||
box.pack( anchor='s', fill='x', side=BOTTOM)
|
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):
|
def copy_name (self, dir, ent):
|
||||||
# This should work as it is the entry's textvariable
|
# This should work as it is the entry's textvariable
|
||||||
|
|
@ -108,24 +101,21 @@ class DemoDirList:
|
||||||
ent.entry.insert(0, self.dlist_dir)
|
ent.entry.insert(0, self.dlist_dir)
|
||||||
|
|
||||||
def okcmd (self):
|
def okcmd (self):
|
||||||
# tixDemo:Status "You have selected the directory" + $self.dlist_dir
|
# tixDemo:Status "You have selected the directory" + self.dlist_dir
|
||||||
|
|
||||||
self.quitcmd()
|
self.quitcmd()
|
||||||
|
|
||||||
def quitcmd (self):
|
def quitcmd (self):
|
||||||
# self.root.destroy()
|
|
||||||
self.exit = 0
|
self.exit = 0
|
||||||
|
|
||||||
def mainloop(self):
|
def mainloop(self):
|
||||||
while self.exit < 0:
|
while self.exit < 0:
|
||||||
self.root.tk.dooneevent(TCL_ALL_EVENTS)
|
self.root.tk.dooneevent(TCL_ALL_EVENTS)
|
||||||
# self.root.tk.dooneevent(TCL_DONT_WAIT)
|
|
||||||
|
|
||||||
def destroy (self):
|
def destroy (self):
|
||||||
self.root.destroy()
|
self.root.destroy()
|
||||||
|
|
||||||
# This "if" statement makes it possible to run this script file inside or
|
# This "if" statement makes it possible to run this script file inside or
|
||||||
# outside of the main demo program "widget".
|
# outside of the main demo program "tixwidgets.py".
|
||||||
#
|
#
|
||||||
if __name__== '__main__' :
|
if __name__== '__main__' :
|
||||||
import tkMessageBox, traceback
|
import tkMessageBox, traceback
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program using tixwish.
|
# program using tixwish.
|
||||||
|
|
@ -19,16 +19,21 @@
|
||||||
import Tix, os, copy
|
import Tix, os, copy
|
||||||
from Tkconstants import *
|
from Tkconstants import *
|
||||||
|
|
||||||
def RunSample (w):
|
TCL_ALL_EVENTS = 0
|
||||||
DemoDirTree(w)
|
|
||||||
|
def RunSample (root):
|
||||||
|
dirtree = DemoDirTree(root)
|
||||||
|
dirtree.mainloop()
|
||||||
|
dirtree.destroy()
|
||||||
|
|
||||||
class DemoDirTree:
|
class DemoDirTree:
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
self.root = w
|
self.root = w
|
||||||
|
self.exit = -1
|
||||||
|
|
||||||
z = w.winfo_toplevel()
|
z = w.winfo_toplevel()
|
||||||
z.wm_title('Tix.DirTree Widget Demo')
|
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
|
||||||
|
|
||||||
# Create the tixDirTree and the tixLabelEntry widgets on the on the top
|
# Create the tixDirTree and the tixLabelEntry widgets on the on the top
|
||||||
# of the dialog box
|
# of the dialog box
|
||||||
|
|
||||||
|
|
@ -90,19 +95,24 @@ class DemoDirTree:
|
||||||
ent.entry.insert(0, self.dlist_dir)
|
ent.entry.insert(0, self.dlist_dir)
|
||||||
|
|
||||||
def okcmd (self):
|
def okcmd (self):
|
||||||
# tixDemo:Status "You have selected the directory" + $self.dlist_dir
|
# tixDemo:Status "You have selected the directory" + self.dlist_dir
|
||||||
|
|
||||||
self.quitcmd()
|
self.quitcmd()
|
||||||
|
|
||||||
def quitcmd (self):
|
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()
|
self.root.destroy()
|
||||||
|
|
||||||
# This "if" statement makes it possible to run this script file inside or
|
# This "if" statement makes it possible to run this script file inside or
|
||||||
# outside of the main demo program "widget".
|
# outside of the main demo program "tixwidgets.py".
|
||||||
#
|
#
|
||||||
if __name__== '__main__' :
|
if __name__== '__main__' :
|
||||||
root=Tix.Tk()
|
root=Tix.Tk()
|
||||||
RunSample(root)
|
RunSample(root)
|
||||||
root.mainloop()
|
|
||||||
root.destroy()
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
@ -59,7 +59,7 @@ def RunSample(w):
|
||||||
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
|
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
|
||||||
|
|
||||||
def ok_command(w):
|
def ok_command(w):
|
||||||
print "Convert file from", demo_opt_from.get(), " to", demo_opt_to.get()
|
# tixDemo:Status "Convert file from %s to %s" % ( demo_opt_from.get(), demo_opt_to.get())
|
||||||
w.destroy()
|
w.destroy()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
# Tix Demostration Program
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
#
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program using tixwish.
|
# program using tixwish.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program using tixwish.
|
# program using tixwish.
|
||||||
|
|
@ -15,94 +15,118 @@
|
||||||
|
|
||||||
import Tix
|
import Tix
|
||||||
|
|
||||||
def RunSample (w) :
|
TCL_ALL_EVENTS = 0
|
||||||
|
|
||||||
# We create the frame and the ScrolledHList widget
|
def RunSample (root):
|
||||||
# at the top of the dialog box
|
shlist = DemoSHList(root)
|
||||||
#
|
shlist.mainloop()
|
||||||
top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
|
shlist.destroy()
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
|
class DemoSHList:
|
||||||
|
def __init__(self, w):
|
||||||
|
self.root = w
|
||||||
|
self.exit = -1
|
||||||
|
|
||||||
for person,boss,name in employees :
|
z = w.winfo_toplevel()
|
||||||
# '.' is the separator character we chose above
|
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
|
||||||
#
|
|
||||||
key= boss + '.' + person
|
# We create the frame and the ScrolledHList widget
|
||||||
# ^^^^ ^^^^^^
|
# at the top of the dialog box
|
||||||
# parent entryPath / child's name
|
#
|
||||||
|
top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
|
||||||
|
|
||||||
hlist.add( key, text=name )
|
# 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)
|
||||||
|
|
||||||
# [Hint] Make sure the keys (e.g. 'boss.person') you choose
|
# This is our little relational database
|
||||||
# are unique names. If you cannot be sure of this (because of
|
#
|
||||||
# the structure of your database, e.g.) you can use the
|
bosses = [
|
||||||
# "add_child" command instead:
|
('jeff', 'Jeff Waxman'),
|
||||||
#
|
('john', 'John Lee'),
|
||||||
# hlist.addchild( boss, text=name)
|
('peter', 'Peter Kenson')
|
||||||
# ^^^^
|
]
|
||||||
# parent entryPath
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
# Use a ButtonBox to hold the buttons.
|
for person,boss,name in employees :
|
||||||
#
|
# '.' is the separator character we chose above
|
||||||
box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
|
#
|
||||||
box.add( 'ok', text='Ok', underline=0, width=6,
|
key= boss + '.' + person
|
||||||
command = lambda w=w: w.quit() )
|
# ^^^^ ^^^^^^
|
||||||
|
# parent entryPath / child's name
|
||||||
|
|
||||||
box.add( 'cancel', text='Cancel', underline=0, width=6,
|
hlist.add( key, text=name )
|
||||||
command = lambda w=w: w.quit() )
|
|
||||||
|
|
||||||
box.pack( side=Tix.BOTTOM, fill=Tix.X)
|
# [Hint] Make sure the keys (e.g. 'boss.person') you choose
|
||||||
top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
|
# 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
|
# This "if" statement makes it possible to run this script file inside or
|
||||||
# outside of the main demo program "widget".
|
# outside of the main demo program "tixwidgets.py".
|
||||||
#
|
#
|
||||||
if __name__== '__main__' :
|
if __name__== '__main__' :
|
||||||
root=Tix.Tk()
|
root=Tix.Tk()
|
||||||
RunSample(root)
|
RunSample(root)
|
||||||
root.mainloop()
|
|
||||||
root.destroy()
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidget": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program using tixwish.
|
# program using tixwish.
|
||||||
|
|
@ -18,128 +18,152 @@
|
||||||
|
|
||||||
import Tix
|
import Tix
|
||||||
|
|
||||||
def RunSample (w) :
|
TCL_ALL_EVENTS = 0
|
||||||
|
|
||||||
# We create the frame and the ScrolledHList widget
|
def RunSample (root):
|
||||||
# at the top of the dialog box
|
shlist = DemoSHList(root)
|
||||||
#
|
shlist.mainloop()
|
||||||
top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
|
shlist.destroy()
|
||||||
|
|
||||||
# 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'] )
|
|
||||||
|
|
||||||
|
class DemoSHList:
|
||||||
|
def __init__(self, w):
|
||||||
|
self.root = w
|
||||||
|
self.exit = -1
|
||||||
|
|
||||||
# Use a ButtonBox to hold the buttons.
|
z = w.winfo_toplevel()
|
||||||
#
|
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
|
||||||
box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
|
|
||||||
box.add( 'ok', text='Ok', underline=0, width=6,
|
# We create the frame and the ScrolledHList widget
|
||||||
command = lambda w=w: w.quit() )
|
# at the top of the dialog box
|
||||||
|
#
|
||||||
|
top = Tix.Frame( w, relief=Tix.RAISED, bd=1)
|
||||||
|
|
||||||
box.add( 'cancel', text='Cancel', underline=0, width=6,
|
# Put a simple hierachy into the HList (two levels). Use colors and
|
||||||
command = lambda w=w: w.quit() )
|
# 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)
|
||||||
|
|
||||||
box.pack( side=Tix.BOTTOM, fill=Tix.X)
|
hlist=top.a.hlist
|
||||||
top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
|
|
||||||
|
# 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
|
# This "if" statement makes it possible to run this script file inside or
|
||||||
# outside of the main demo program "widget".
|
# outside of the main demo program "tixwidgets.py".
|
||||||
#
|
#
|
||||||
if __name__== '__main__' :
|
if __name__== '__main__' :
|
||||||
root=Tix.Tk()
|
root=Tix.Tk()
|
||||||
RunSample(root)
|
RunSample(root)
|
||||||
root.mainloop()
|
|
||||||
root.destroy()
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/local/bin/python
|
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Tix Demostration Program
|
# Tix Demostration Program
|
||||||
#
|
#
|
||||||
# This sample program is structured in such a way so that it can be
|
# 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
|
# executed from the Tix demo program "tixwidgets.py": it must have a
|
||||||
# procedure called "RunSample". It should also have the "if" statment
|
# 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
|
# at the end of this file so that it can be run as a standalone
|
||||||
# program.
|
# program.
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,8 @@ class Demo:
|
||||||
text += line + '\n'
|
text += line + '\n'
|
||||||
try: tkMessageBox.showerror ('Error', text)
|
try: tkMessageBox.showerror ('Error', text)
|
||||||
except: pass
|
except: pass
|
||||||
tkinspect_quit (1)
|
self.exit = 1
|
||||||
|
raise SystemExit, 1
|
||||||
|
|
||||||
def destroy (self):
|
def destroy (self):
|
||||||
self.root.destroy()
|
self.root.destroy()
|
||||||
|
|
@ -420,9 +421,13 @@ def MkFileEnt(w):
|
||||||
ent.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
|
ent.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
|
||||||
|
|
||||||
def MkFileBox(w):
|
def MkFileBox(w):
|
||||||
|
"""The FileSelectBox is a Motif-style box with various enhancements.
|
||||||
|
For example, you can adjust the size of the two listboxes
|
||||||
|
and your past selections are recorded.
|
||||||
|
"""
|
||||||
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 TixFileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.')
|
text='The Tix FileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.')
|
||||||
box = Tix.FileSelectBox(w)
|
box = Tix.FileSelectBox(w)
|
||||||
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)
|
||||||
box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
|
box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue