0
|
1 ## Copyright (C) 1998, 1999, 2000 Joao Cardoso. |
|
2 ## |
|
3 ## This program is free software; you can redistribute it and/or modify it |
|
4 ## under the terms of the GNU General Public License as published by the |
|
5 ## Free Software Foundation; either version 2 of the License, or (at your |
|
6 ## option) any later version. |
|
7 ## |
|
8 ## This program is distributed in the hope that it will be useful, but |
|
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 ## General Public License for more details. |
|
12 ## |
|
13 ## This file is part of tk_octave. |
|
14 |
|
15 ## tk_busy (text) |
|
16 ## |
|
17 ## Opens a new window with 'text' printed end with a flashing hourglass. |
|
18 ## |
|
19 ## If called with no arguments, close the window. |
|
20 ## If the window already exists, 'text' is updated |
|
21 ## Only one tk_busy window is allowed at one time. |
|
22 ## |
|
23 ## Octave can continue processing while the hourglass is flashing. |
|
24 |
|
25 ## 2001-09-14 Paul Kienzle <pkienzle@users.sf.net> |
|
26 ## * convert to pthreads version of octave |
|
27 ## * fix grammar in documentation |
|
28 |
|
29 function tk_busy (text) |
|
30 |
|
31 eval("tk_interp",""); |
|
32 |
|
33 if (nargin == 0) |
|
34 tk_cmd( "foreach i [after info] {after cancel $i}" ); |
|
35 tk_cmd( sprintf("proc rep {} {}") ); |
|
36 tk_cmd( "destroy .top_tk_busy" ); |
|
37 elseif (tk_cmd( "winfo exists .top_tk_busy" ) == "1") |
|
38 tk_cmd ( sprintf("set tk_busy_message \"%s\"", text) ); |
|
39 tk_cmd( sprintf( "wm title .top_tk_busy {%s}", text) ); |
|
40 else |
|
41 tk_cmd( "toplevel .top_tk_busy -borderwidth 2 -relief groove" ); |
|
42 tk_cmd( sprintf( "wm title .top_tk_busy {%s}", text) ); |
|
43 #tk_cmd( "wm withdraw .top_tk_busy" ); |
|
44 tk_cmd( "label .top_tk_busy.l1 -textvar tk_busy_message -relief ridge -padx 10 -pady 5"); |
|
45 tk_cmd (sprintf("set tk_busy_message \"%s\"", text)); |
|
46 tk_cmd ("button .top_tk_busy.b1 -bitmap hourglass"); |
|
47 |
|
48 #tk_cmd("wm overrideredirect .top_tk_busy 1"); |
|
49 |
|
50 tk_cmd("pack .top_tk_busy.l1 .top_tk_busy.b1 \ |
|
51 -ipadx 2 -ipady 2 -padx 10 -pady 10"); |
|
52 |
|
53 #tk_cmd("wm deiconify .top_tk_busy"); |
|
54 |
|
55 tk_cmd("proc rep {a b} { .top_tk_busy.b1 configure \ |
|
56 -foreground $a -background $b; after 1000 rep $b $a}"); |
|
57 tk_cmd("rep salmon green4"); |
|
58 endif |
|
59 |
|
60 endfunction |