1 #!/usr/local/bin/python
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": 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
13 # This file demonstrates the use of the tixNoteBook widget, which allows
14 # you to lay out your interface using a "notebook" metaphore
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
)
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"
37 nb
= Tix
.NoteBook(w
, name
='nb', ipadx
=6, ipady
=6)
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
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 #----------------------------------------
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
)
106 def createCommonButtons(master
):
107 ok
= Tix
.Button(master
, name
='ok', text
='OK', width
=6,
109 cancel
= Tix
.Button(master
, name
='cancel',
110 text
='Cancel', width
=6,
113 ok
.pack(side
=Tix
.TOP
, padx
=2, pady
=2)
114 cancel
.pack(side
=Tix
.TOP
, padx
=2, pady
=2)
116 if __name__
== '__main__':