Issue #6615: logging: Used weak references in internal handler list. Thanks to flox...
[python.git] / Demo / tix / samples / NoteBook.py
blob1e0da3e76a6f37aed71b65e2a60dfd1b3e788678
1 # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
3 # $Id$
5 # Tix Demostration Program
7 # This sample program is structured in such a way so that it can be
8 # executed from the Tix demo program "tixwidgets.py": it must have a
9 # procedure called "RunSample". It should also have the "if" statment
10 # at the end of this file so that it can be run as a standalone
11 # program.
13 # This file demonstrates the use of the tixNoteBook widget, which allows
14 # you to lay out your interface using a "notebook" metaphore
16 import Tix
18 def RunSample(w):
19 global root
20 root = w
22 # We use these options to set the sizes of the subwidgets inside the
23 # notebook, so that they are well-aligned on the screen.
24 prefix = Tix.OptionName(w)
25 if prefix:
26 prefix = '*'+prefix
27 else:
28 prefix = ''
29 w.option_add(prefix+'*TixControl*entry.width', 10)
30 w.option_add(prefix+'*TixControl*label.width', 18)
31 w.option_add(prefix+'*TixControl*label.anchor', Tix.E)
32 w.option_add(prefix+'*TixNoteBook*tagPadX', 8)
34 # Create the notebook widget and set its backpagecolor to gray.
35 # Note that the -backpagecolor option belongs to the "nbframe"
36 # subwidget.
37 nb = Tix.NoteBook(w, name='nb', ipadx=6, ipady=6)
38 nb['bg'] = 'gray'
39 nb.nbframe['backpagecolor'] = 'gray'
41 # Create the two tabs on the notebook. The -underline option
42 # puts a underline on the first character of the labels of the tabs.
43 # Keyboard accelerators will be defined automatically according
44 # to the underlined character.
45 nb.add('hard_disk', label="Hard Disk", underline=0)
46 nb.add('network', label="Network", underline=0)
48 nb.pack(expand=1, fill=Tix.BOTH, padx=5, pady=5 ,side=Tix.TOP)
50 #----------------------------------------
51 # Create the first page
52 #----------------------------------------
53 # Create two frames: one for the common buttons, one for the
54 # other widgets
56 tab=nb.hard_disk
57 f = Tix.Frame(tab)
58 common = Tix.Frame(tab)
60 f.pack(side=Tix.LEFT, padx=2, pady=2, fill=Tix.BOTH, expand=1)
61 common.pack(side=Tix.RIGHT, padx=2, fill=Tix.Y)
63 a = Tix.Control(f, value=12, label='Access time: ')
64 w = Tix.Control(f, value=400, label='Write Throughput: ')
65 r = Tix.Control(f, value=400, label='Read Throughput: ')
66 c = Tix.Control(f, value=1021, label='Capacity: ')
68 a.pack(side=Tix.TOP, padx=20, pady=2)
69 w.pack(side=Tix.TOP, padx=20, pady=2)
70 r.pack(side=Tix.TOP, padx=20, pady=2)
71 c.pack(side=Tix.TOP, padx=20, pady=2)
73 # Create the common buttons
74 createCommonButtons(common)
76 #----------------------------------------
77 # Create the second page
78 #----------------------------------------
80 tab = nb.network
82 f = Tix.Frame(tab)
83 common = Tix.Frame(tab)
85 f.pack(side=Tix.LEFT, padx=2, pady=2, fill=Tix.BOTH, expand=1)
86 common.pack(side=Tix.RIGHT, padx=2, fill=Tix.Y)
88 a = Tix.Control(f, value=12, label='Access time: ')
89 w = Tix.Control(f, value=400, label='Write Throughput: ')
90 r = Tix.Control(f, value=400, label='Read Throughput: ')
91 c = Tix.Control(f, value=1021, label='Capacity: ')
92 u = Tix.Control(f, value=10, label='Users: ')
94 a.pack(side=Tix.TOP, padx=20, pady=2)
95 w.pack(side=Tix.TOP, padx=20, pady=2)
96 r.pack(side=Tix.TOP, padx=20, pady=2)
97 c.pack(side=Tix.TOP, padx=20, pady=2)
98 u.pack(side=Tix.TOP, padx=20, pady=2)
100 createCommonButtons(common)
102 def doDestroy():
103 global root
104 root.destroy()
106 def createCommonButtons(master):
107 ok = Tix.Button(master, name='ok', text='OK', width=6,
108 command=doDestroy)
109 cancel = Tix.Button(master, name='cancel',
110 text='Cancel', width=6,
111 command=doDestroy)
113 ok.pack(side=Tix.TOP, padx=2, pady=2)
114 cancel.pack(side=Tix.TOP, padx=2, pady=2)
116 if __name__ == '__main__':
117 root = Tix.Tk()
118 RunSample(root)
119 root.mainloop()