hwtk::progressbar

Show the progress of an ongoing task.

Format

hwtk::progressbar - pathName ?option value? …

Description

A hwtk::progressbar widget is used to show the progress of an ongoing task. There are two types of progress bar. A determinate progress bar shows approximately how far a defined task has progressed by how much of the bar is filled. An indeterminate progress bar shows that the program is busy, but does not give an indication of how much of the given task has progressed.

Standard Options

-clientdata
Database name: clientData
Database class: ClientData
Acts as a data storage for a widgets. User can store any data and this will not have any effect on widget property.
-cursor
Database name: cursor
Database class: Cursor
Specifies the mouse cursor to be used for the widget. See Tk_GetCursor and cursors(n) in the Tk reference manual for the legal values. If set to the empty string (the default), the cursor is inherited from the parent widget.
-help
Database name: help
Database class: Text
Specifies the text or help message that displays when the cursor moves over the widget.
-helpcommand
Database name: helpcommand
Database class: Command
Dynamic help which calls an assigned -helpcommand when the user moves the mouse on the widget. The text which is returned by the -helpcommand will be in turn be displayed on the tooltip.

Widget-Specific Options

-length
Database name: length
Database class: Length
Specifies the desired length for the progress bar in screen units (i.e. any of the forms acceptable to Tk_GetPixels). For vertical progress bars this is the progress bar’s height; for horizontal progress bars it is the width.
-mode
Database name: mode
Database class: ProgressMode
Specifies the mode of the progress bar. Can be either of the following options:
determinate
Progress bar fills up as the task progresses, giving an estimate of the status of the task’s completion
indeterminate
Filled section of the progress bar moves back and forth, showing that the task is ongoing but giving no indication of the relative completion of the task
-maximum
Database name: maximum
Database class: Maximum
A floating point number specifying the maximum -value. Defaults to 100.
-orient
Database name: orient
Database class: Orient
Specifies the orientation of the progress bar. Can be horizontal or vertical; default is horizontal.
-variable
Database name: variable
Database class: Variable
Specifies the name of a global variable to link to the progress bar. Whenever the value of the variable changes, the progress bar will update to reflect this value.
-value
Database name: value
Database class: Value
Specifies the current floating-point value of the progress bar’s variable.

Widget Command

In addition to the standard configure, cget, identify, instate, and state commands, this command support the following additional widget commands:
pathName configure ?option? ?value option value …?
Query or modify the configuration options of the widget. If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. If option is specified with no value, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. If no option is specified, returns a list describing all of the available options for pathName.
pathName cget option
Returns the current value of the configuration option given by option.
pathName identify element x y
Returns the name of the element under the point given by x and y, or an empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget. Some widgets accept other identify subcommands.
pathName instate statespec ?script?
Test the widget’s state. If script is not specified, returns 1 if the widget state matches statespec and 0 otherwise. If script is specified, equivalent to
if{[pathNameinstatestateSpec]}script
pathName state ?stateSpec?
Modify or inquire widget state. If stateSpec is present, sets the widget state: for each flag in stateSpec, sets the corresponding flag or clears it if prefixed by an exclamation point. Returns a new state spec indicating which flags were changed:
setchanges[pathNamestatespec]
pathNamestate$changes
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.
pathName start ?interval?
Begin autoincrement mode: schedules a recurring timer event that calls step every interval milliseconds. If omitted, interval defaults to 50 milliseconds (20 steps/second).
pathName step ?amount?
Increments the progressbar indicator by amount. If omitted, amount defaults to 1.0.
pathName stop
Stop autoincrement mode: cancels any recurring timer event initiated by start.

Example

proc doBars {op args} {
    foreach w $args {
    $w $op
    }
}


hwtk::dialog .dlg -title "::hwtk::progressbar"
set w [.dlg recess]

hwtk::frame $w.f
pack $w.f -fill both -expand 1
set w $w.f

label $w.11 -text "Determinate" 
hwtk::progessbar $w.p1 -mode determinate
label $w.12 -text "Indeterminate"
hwtk::progessbar $w.p2 -mode indeterminate
hwtk::button $w.start -text "Start Progress" -command [list::hwtk::demo::doBars start $w.p1 $w.p2]
hwtk::button $w.stop -text "Stop Progress" -command [list::hwtk::demo::doBars stop $w.p1 $w.p2]

grid $w.11 - -pady 5 -padx 10
grid $w.p1 - -pady 5 -padx 10
grid $w.12 - -pady 5 -padx 10
grid $w.p2 - -pady 5 -padx 10
grid $w.start $w.stop - -pady 10 -padx 5
grid configure $w.start -sticky e
grid configure $w.stop -sticky w
grid columnconfigure $w all -weight 1

.dlg post