Updateable Message Widget [message #4755] |
Tue, 01 August 1995 00:00  |
cavanaug
Messages: 18 Registered: December 1994
|
Junior Member |
|
|
I've been trying to develop a clean method of having an updateable window
in some of my larger programs. The plan is to use this window to keep the program
user current on the program's processing status (rather than just printing to the
xterm). I finally settled on the method below, but it's not as clean as I would like.
Notice that the widget is realized but not registered (and therefore, I assume, needs
no event handler), and that to destroy the widget, I have to pass widget id - 1 to
widget_control. Weird. Does anyone have a better way of handling this?
Thanks in advance,
Charles
function updatebox, title = title, message = message, xsize = xsize, ysize = ysize
; IDL 4.0, AIX 4.1
; get the dimensions, message and title
if n_elements (xsize) eq 0 then xsize = 300
if n_elements (ysize) eq 0 then ysize = 50
if n_elements (title) eq 0 then title = ' MESSAGE!! '
if n_elements (message) eq 0 then message = ' '
; create the box
base = widget_base (title = title, /column)
upid = widget_label (base, value = message, xsize = xsize, ysize = ysize)
; realize but dont register (this is the only way I could return the widget id)
widget_control, base, /realize
; return the id of the writeable section of the box
return, upid
end
pro utest
boxid = updatebox (title = "Update Test", xsize = 200, ysize = 30)
widget_control, boxid, set_value = "ID of this box is " + strtrim (boxid, 2)
wait, 1.0 ; simulate doing something
widget_control, boxid, set_value = "Doing something . . ."
wait, 1.0
widget_control, boxid, set_value = "Doing another thing . . ."
wait, 1.0
widget_control, boxid, set_value = "Last thing to do . . ."
wait, 1.0
widget_control, boxid - 1, /destroy
end
--
Charles Cavanaugh | "Words are very unnecessary, they can only do harm"
cavanaug@ncar.ucar.edu | - Depeche Mode
NCAR Boulder, CO, USA | "Facts all come with points of view"
My opinions | - Talking Heads
|
|
|