Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | # spin.tcl -- |
2 | # | |
3 | # This demonstration script creates several spinbox widgets. | |
4 | # | |
5 | # RCS: @(#) $Id: spin.tcl,v 1.1 2001/10/30 11:21:50 dkf Exp $ | |
6 | ||
7 | if {![info exists widgetDemo]} { | |
8 | error "This script should be run from the \"widget\" demo." | |
9 | } | |
10 | ||
11 | set w .spin | |
12 | catch {destroy $w} | |
13 | toplevel $w | |
14 | wm title $w "Spinbox Demonstration" | |
15 | wm iconname $w "spin" | |
16 | positionWindow $w | |
17 | ||
18 | label $w.msg -font $font -wraplength 5i -justify left -text "Three different\ | |
19 | spin-boxes are displayed below. You can add characters by pointing,\ | |
20 | clicking and typing. The normal Motif editing characters are\ | |
21 | supported, along with many Emacs bindings. For example, Backspace\ | |
22 | and Control-h delete the character to the left of the insertion\ | |
23 | cursor and Delete and Control-d delete the chararacter to the right\ | |
24 | of the insertion cursor. For values that are too large to fit in the\ | |
25 | window all at once, you can scan through the value by dragging with\ | |
26 | mouse button2 pressed. Note that the first spin-box will only permit\ | |
27 | you to type in integers, and the third selects from a list of\ | |
28 | Australian cities." | |
29 | pack $w.msg -side top | |
30 | ||
31 | frame $w.buttons | |
32 | pack $w.buttons -side bottom -fill x -pady 2m | |
33 | button $w.buttons.dismiss -text Dismiss -command "destroy $w" | |
34 | button $w.buttons.code -text "See Code" -command "showCode $w" | |
35 | pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 | |
36 | ||
37 | set australianCities { | |
38 | Canberra Sydney Melbourne Perth Adelaide Brisbane | |
39 | Hobart Darwin "Alice Springs" | |
40 | } | |
41 | ||
42 | spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ | |
43 | -vcmd {string is integer %P} | |
44 | spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 | |
45 | spinbox $w.s3 -values $australianCities -width 10 | |
46 | ||
47 | #entry $w.e1 | |
48 | #entry $w.e2 | |
49 | #entry $w.e3 | |
50 | pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 ;#-fill x | |
51 | ||
52 | #$w.e1 insert 0 "Initial value" | |
53 | #$w.e2 insert end "This entry contains a long value, much too long " | |
54 | #$w.e2 insert end "to fit in the window at one time, so long in fact " | |
55 | #$w.e2 insert end "that you'll have to scan or scroll to see the end." |