1 |
578 |
markom |
# Tix Demostration Program
|
2 |
|
|
#
|
3 |
|
|
# This sample program is structured in such a way so that it can be
|
4 |
|
|
# executed from the Tix demo program "widget": it must have a
|
5 |
|
|
# procedure called "RunSample". It should also have the "if" statment
|
6 |
|
|
# at the end of this file so that it can be run as a standalone
|
7 |
|
|
# program using tixwish.
|
8 |
|
|
|
9 |
|
|
# This program demonstrates the ListBoteBook widget, which is very similar
|
10 |
|
|
# to a NoteBook widget but uses an HList instead of page tabs to list the
|
11 |
|
|
# pages.
|
12 |
|
|
|
13 |
|
|
proc RunSample {w} {
|
14 |
|
|
set top [frame $w.f -bd 1 -relief raised]
|
15 |
|
|
set box [tixButtonBox $w.b -bd 1 -relief raised]
|
16 |
|
|
|
17 |
|
|
pack $box -side bottom -fill both
|
18 |
|
|
pack $top -side top -fill both -expand yes
|
19 |
|
|
|
20 |
|
|
#----------------------------------------------------------------------
|
21 |
|
|
# Create the ListNoteBook with nice icons
|
22 |
|
|
#----------------------------------------------------------------------
|
23 |
|
|
tixListNoteBook $top.n -ipadx 6 -ipady 6
|
24 |
|
|
|
25 |
|
|
set img0 [tix getimage harddisk]
|
26 |
|
|
set img1 [tix getimage network]
|
27 |
|
|
|
28 |
|
|
$top.n subwidget hlist add hard_disk -itemtype imagetext \
|
29 |
|
|
-image $img0 -text "Hard Disk" -under 0
|
30 |
|
|
$top.n subwidget hlist add network -itemtype imagetext \
|
31 |
|
|
-image $img1 -text "Network" -under 0
|
32 |
|
|
|
33 |
|
|
$top.n add hard_disk
|
34 |
|
|
$top.n add network
|
35 |
|
|
|
36 |
|
|
#
|
37 |
|
|
# Create the widgets inside the two pages
|
38 |
|
|
|
39 |
|
|
# We use these options to set the sizes of the subwidgets inside the
|
40 |
|
|
# notebook, so that they are well-aligned on the screen.
|
41 |
|
|
#
|
42 |
|
|
set name [tixOptionName $w]
|
43 |
|
|
option add *$name*TixControl*entry.width 10
|
44 |
|
|
option add *$name*TixControl*label.width 18
|
45 |
|
|
option add *$name*TixControl*label.anchor e
|
46 |
|
|
|
47 |
|
|
set f [$top.n subwidget hard_disk]
|
48 |
|
|
|
49 |
|
|
tixControl $f.a -value 12 -label "Access Time: "
|
50 |
|
|
tixControl $f.w -value 400 -label "Write Throughput: "
|
51 |
|
|
tixControl $f.r -value 400 -label "Read Throughput: "
|
52 |
|
|
tixControl $f.c -value 1021 -label "Capacity: "
|
53 |
|
|
pack $f.a $f.w $f.r $f.c -side top -padx 20 -pady 2
|
54 |
|
|
|
55 |
|
|
set f [$top.n subwidget network]
|
56 |
|
|
|
57 |
|
|
tixControl $f.a -value 12 -label "Access Time: "
|
58 |
|
|
tixControl $f.w -value 400 -label "Write Throughput: "
|
59 |
|
|
tixControl $f.r -value 400 -label "Read Throughput: "
|
60 |
|
|
tixControl $f.c -value 1021 -label "Capacity: "
|
61 |
|
|
tixControl $f.u -value 10 -label "Users: "
|
62 |
|
|
|
63 |
|
|
pack $f.a $f.w $f.r $f.c $f.u -side top -padx 20 -pady 2
|
64 |
|
|
|
65 |
|
|
pack $top.n -expand yes -fill both -padx 5 -pady 5
|
66 |
|
|
|
67 |
|
|
# Create the buttons
|
68 |
|
|
#
|
69 |
|
|
$box add ok -text Ok -command "destroy $w" -width 6
|
70 |
|
|
$box add cancel -text Cancel -command "destroy $w" -width 6
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
#----------------------------------------------------------------------
|
74 |
|
|
# Start-up code
|
75 |
|
|
#----------------------------------------------------------------------
|
76 |
|
|
|
77 |
|
|
if {![info exists tix_demo_running]} {
|
78 |
|
|
wm withdraw .
|
79 |
|
|
set w .demo
|
80 |
|
|
toplevel $w
|
81 |
|
|
RunSample $w
|
82 |
|
|
bind $w <Destroy> exit
|
83 |
|
|
}
|