OSDN Git Service

Initial revision
[pf3gnuchains/sourceware.git] / itcl / iwidgets3.0.0 / demos / notebook
1 #!/bin/sh
2 # ----------------------------------------------------------------------
3 #  DEMO: notebook in [incr Widgets]
4 # ----------------------------------------------------------------------
5 #\
6 exec itkwish "$0" ${1+"$@"}
7 package require Iwidgets 3.0
8
9 # itkwish interprets the rest...
10 # ----------------------------------------------------------------------
11 option add *textBackground seashell
12 option add *Scale.width 8
13 . configure -background white
14
15 iwidgets::optionmenu .pages -labeltext "Page:" -command {
16     .nb view [.pages get]
17 }
18 pack .pages -padx 4 -pady 4
19 .pages insert end "Personal Info" "Favorite Color" "Blank Page"
20
21
22 iwidgets::notebook .nb -width 3i -height 2.6i
23 pack .nb -padx 4 -pady 4
24  
25 # Page #1
26 # ----------------------------------------------------------------------
27 set page [.nb add -label "Personal Info"]
28
29 iwidgets::entryfield $page.name -labeltext "Name:" -labelpos nw
30 pack $page.name
31 iwidgets::entryfield $page.addr -labeltext "Address:" -labelpos nw
32 pack $page.addr
33 iwidgets::entryfield $page.addr2 -labeltext "City, State:" -labelpos nw
34 pack $page.addr2
35 iwidgets::entryfield $page.email -labeltext "E-mail:" -labelpos nw
36 pack $page.email
37
38
39 # Page #2
40 # ----------------------------------------------------------------------
41 set page [.nb add -label "Favorite Color"]
42
43 frame $page.sample -width 20 -height 20 \
44     -borderwidth 2 -relief raised
45 pack $page.sample -fill both -pady 4
46 scale $page.r -label "Red" -orient horizontal \
47     -from 0 -to 255 -command "set_color $page"
48 pack $page.r -fill x
49 scale $page.g -label "Green" -orient horizontal \
50     -from 0 -to 255 -command "set_color $page"
51 pack $page.g -fill x
52 scale $page.b -label "Blue" -orient horizontal \
53     -from 0 -to 255 -command "set_color $page"
54 pack $page.b -fill x
55
56 proc set_color {page {val 0}} {
57     set r [$page.r get]
58     set g [$page.g get]
59     set b [$page.b get]
60     set color [format "#%.2x%.2x%.2x" $r $g $b]
61     $page.sample configure -background $color
62 }
63 set_color $page
64  
65
66 # Page #3
67 # ----------------------------------------------------------------------
68 set page [.nb add -label "Blank Page"]
69
70 label $page.title -text "(put your widgets here)" \
71     -background black -foreground white \
72     -width 25 -height 3
73 pack $page.title -expand yes -fill both
74
75
76 .nb view "Personal Info"