summaryrefslogtreecommitdiff
path: root/iwidgets/demos/spinner
diff options
context:
space:
mode:
Diffstat (limited to 'iwidgets/demos/spinner')
-rw-r--r--iwidgets/demos/spinner28
1 files changed, 28 insertions, 0 deletions
diff --git a/iwidgets/demos/spinner b/iwidgets/demos/spinner
new file mode 100644
index 00000000000..703bfa1d7d7
--- /dev/null
+++ b/iwidgets/demos/spinner
@@ -0,0 +1,28 @@
+# ----------------------------------------------------------------------
+# DEMO: spinner in [incr Widgets]
+# ----------------------------------------------------------------------
+package require Iwidgets 4.0
+
+option add *textBackground seashell
+
+proc spinMonth {win step} {
+ set months {
+ January February March April
+ May June July August September
+ October November December
+ }
+
+ set index [expr [lsearch $months [$win get]] + $step]
+
+ if {$index < 0} {set index 11}
+ if {$index > 11} {set index 0}
+
+ $win delete 0 end
+ $win insert 0 [lindex $months $index]
+}
+
+iwidgets::spinner .sm -labeltext "Month:" -width 10 -fixed 10 \
+ -decrement {spinMonth .sm -1} -increment {spinMonth .sm 1}
+
+pack .sm
+.sm insert 0 "January"