source: tol/tolbase/lib/byswidget/bfunctions/progressbar.tcl @ 6d7779d

1941-docker-image-to-testdevel
Last change on this file since 6d7779d was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : progressbar.tcl
3# PURPOSE : facilitates the use of a progress bar in tcl
4#/////////////////////////////////////////////////////////////////////////////
5
6namespace eval ::progressbar {
7  variable data
8}
9
10#/////////////////////////////////////////////////////////////////////////////
11proc ::progressbar::Show { {title ""} {w 20} {h 2} {tolvar {}}} {
12#/////////////////////////////////////////////////////////////////////////////
13  variable data
14 
15  set cmd {}
16  set stop {}
17 
18  if { [llength $tolvar] } {
19    set cmd "::progressbar::AbortAndDestroy $tolvar"
20    set stop [mc "Abort"]
21  }
22 
23  ProgressDlg .__ProgressBarDialog -title  $title \
24    -variable     ::progressbar::data(var) \
25    -textvariable ::progressbar::data(txt) \
26    -width $w -height $h -stop $stop -command $cmd
27  wm protocol .__ProgressBarDialog WM_DELETE_WINDOW [list ::progressbar::Destroy]   
28  set data(var) 0
29  update
30}
31
32
33#/////////////////////////////////////////////////////////////////////////////
34proc ::progressbar::Destroy { } {
35#/////////////////////////////////////////////////////////////////////////////
36  variable data
37     
38  destroy .__ProgressBarDialog
39  set data(var) ""
40  set data(txt) ""
41}
42
43
44#/////////////////////////////////////////////////////////////////////////////
45proc ::progressbar::Set { p } {
46#/////////////////////////////////////////////////////////////////////////////
47  variable data
48                               
49  set data(var) $p
50  update
51}
52
53
54#/////////////////////////////////////////////////////////////////////////////
55proc ::progressbar::SetText { t } {
56#/////////////////////////////////////////////////////////////////////////////
57  variable data
58                                     
59  set data(txt) $t
60  update
61}
62
63
64#/////////////////////////////////////////////////////////////////////////////
65proc ::progressbar::AbortAndDestroy { tolvar } {
66#/////////////////////////////////////////////////////////////////////////////
67  ::tol::console eval "Real $tolvar := (1.0)"
68  ::tol::console stack release $tolvar
69  ::progressbar::Destroy
70}
Note: See TracBrowser for help on using the repository browser.