summaryrefslogtreecommitdiffstats
path: root/library/ttk/progress.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/ttk/progress.tcl')
-rw-r--r--library/ttk/progress.tcl49
1 files changed, 49 insertions, 0 deletions
diff --git a/library/ttk/progress.tcl b/library/ttk/progress.tcl
new file mode 100644
index 0000000..b6e2ffb
--- /dev/null
+++ b/library/ttk/progress.tcl
@@ -0,0 +1,49 @@
+#
+# Ttk widget set: progress bar utilities.
+#
+
+namespace eval ttk::progressbar {
+ variable Timers ;# Map: widget name -> after ID
+}
+
+# Autoincrement --
+# Periodic callback procedure for autoincrement mode
+#
+proc ttk::progressbar::Autoincrement {pb steptime stepsize} {
+ variable Timers
+
+ if {![winfo exists $pb]} {
+ # widget has been destroyed -- cancel timer
+ unset -nocomplain Timers($pb)
+ return
+ }
+
+ $pb step $stepsize
+
+ set Timers($pb) [after $steptime \
+ [list ttk::progressbar::Autoincrement $pb $steptime $stepsize] ]
+}
+
+# ttk::progressbar::start --
+# Start autoincrement mode. Invoked by [$pb start] widget code.
+#
+proc ttk::progressbar::start {pb {steptime 50} {stepsize 1}} {
+ variable Timers
+ if {![info exists Timers($pb)]} {
+ Autoincrement $pb $steptime $stepsize
+ }
+}
+
+# ttk::progressbar::stop --
+# Cancel autoincrement mode. Invoked by [$pb stop] widget code.
+#
+proc ttk::progressbar::stop {pb} {
+ variable Timers
+ if {[info exists Timers($pb)]} {
+ after cancel $Timers($pb)
+ unset Timers($pb)
+ }
+ $pb configure -value 0
+}
+
+