Skip to content

Scale and Progressbar

Andrej Vodopivec edited this page Mar 13, 2015 · 2 revisions

Progressbar shows the progress from 0 to the value configured with :maximum.

Functions implemented for progressbar

  • (progressbar-start p &optional interval)
  • (progressbar-stop p)
  • (progressbar-step p &optional step)

A scale can be used to control a double variable from the value configured with :from to the value configure with :to.

In the example all progressbars and scales are controlled with a single variable.

Scale and Progressbar

(defpackage :tk-user
  (:use :cl :tk)
  (:export :main))

(in-package :tk-user)

(defun main ()
  (with-tk-root (root)
    (setf (window-title root) "Progress / Scale")
    
    (let ((var (float-var))
          (f (frame :parent root :padding '(10 10 10 10))))

      (pack f :expand t :fill "both")

      (pack (scale :parent f :from 0 :to 50 :orient "vertical" :variable var)
            :padx 10 :pady 10 :side "left")
      (pack (scale :parent f :from 0 :to 50 :orient "horizontal" :variable var)
            :padx 10 :pady 10 :side "left")
      (pack (separator :parent f :orient "vertical")
            :fill "y" :side "left")

      (pack (progressbar :parent f :maximum 50 :orient "vertical" :variable var)
            :padx 10 :pady 10 :side "right")
      (pack (progressbar :parent f :maximum 50 :orient "horizontal" :variable var)
            :padx 10 :pady 10 :side "right")
      (pack (separator :parent f :orient "vertical")
            :fill "y" :side "right")

      (pack (entry :parent f :textvariable var)
            :padx 10 :pady 10 :side "top" :expand t)

      (setf (var-value var) 25))))

Tcl/Tk documentation for progressbar.

Tcl/Tk documentation for scale.

Clone this wiki locally