WIDGETS [message #2717] |
Tue, 30 August 1994 10:23  |
mallozzi
Messages: 60 Registered: August 1994
|
Member |
|
|
I recently began to use IDL WIDGETS (on DEC ALPHA) and I have a minor problem: I created a base WIDGET with multiple editable text children to be used as
an editable menu. I invoke the WIDGET and register it with XMANAGER, with
the keyword JUST_REG. When I want control of the WIDGET, I type XMANAGER,widget_id. The problem is as follows: I want to be able to desensitize some of the children, so the user can only alter a single menu entry (I am running a complicated IDL code concurrently). I thought I could destroy the WIDGET and rebuild it with only one child sensitive. Is this possible, or is there a more appropriate method? Thanks -Bob
|
|
|
|
|
Re: WIDGETS [message #2888 is a reply to message #2717] |
Thu, 01 September 1994 14:03   |
peter
Messages: 80 Registered: February 1994
|
Member |
|
|
Joseph M Zawodny (zawodny@arbd0.larc.nasa.gov) wrote:
: No, no, no! You should avoid using common blocks in widget programming. I
: sense and desense widgets of all sorts routinely. My personal preference
: is to create a structure with one of the fields set to be a long integer
: array and I store the widget id's of the widgets I need to manipulate or
: (de)sensitize in this array (the structure is required only if you need to
: pass other data besides the widget id's). That way a simple
: widget_control,event.id,get_uvalue=array
But how do you sensitize/desensitize a widget that you didn't get an
event from? Suppose I perform an action that requires, say, the fields
in another base widget to change. I have to have their widget IDs, so
I need a common block, unless I store all of them in the uvalue of
every widget that might require them to change (which seems a little hard to
maintain (ah, the quick and dirty programming thread again!)).
: statement gets the info I need without using common blocks. The problem is
: that you might have multiple versions of the same widget running
: concurrently. If you do and use common blocks to pass data between
: widgets, the common blocks can (and do) get scrambled.
This is a problem -- I've only ever written applications where unique
instances of widgets are allowed, in which case a common block to hold
widget IDs, and another one to hold the panel state (i.e. the values of
variables that affect that panel) seems to work very well indeed.
Peter
|
|
|
Re: WIDGETS [message #2895 is a reply to message #2717] |
Thu, 01 September 1994 10:30   |
zawodny
Messages: 121 Registered: August 1992
|
Senior Member |
|
|
In article <344g63$b8r@sun4.bham.ac.uk> sjt@xun8.sr.bham.ac.uk (James Tappin) writes:
> mallozzi@ssl.msfc.nasa.gov wrote:
> : I recently began to use IDL WIDGETS (on DEC ALPHA) and I have a minor
> : problem: I created a base WIDGET with multiple editable text children
> : to be used as
> : an editable menu. I invoke the WIDGET and register it with XMANAGER, with
> : the keyword JUST_REG. When I want control of the WIDGET, I type
> : XMANAGER, widget_id. The problem is as follows: I want to be able to
> : desensitize some of the children, so the user can only alter a single
> : menu entry (I am running a complicated IDL code
> : concurrently). I thought I could destroy the WIDGET and rebuild it with
> : only one child sensitive. Is this possible, or is there a more
> : appropriate method? Thanks -Bob
>
> If you save the ID's of the widgets which you want to change in a common
> block, then you can just use WIDGET_CONTROL, SENSITIVE=1 (or 0) to
> (de)sensitize the relevant widgets.
>
> --
> James Tappin,
No, no, no! You should avoid using common blocks in widget programming. I
sense and desense widgets of all sorts routinely. My personal preference
is to create a structure with one of the fields set to be a long integer
array and I store the widget id's of the widgets I need to manipulate or
(de)sensitize in this array (the structure is required only if you need to
pass other data besides the widget id's). That way a simple
widget_control,event.id,get_uvalue=array
statement gets the info I need without using common blocks. The problem is
that you might have multiple versions of the same widget running
concurrently. If you do and use common blocks to pass data between
widgets, the common blocks can (and do) get scrambled.
--
Joseph M. Zawodny (KO4LW) NASA Langley Research Center
Internet: zawodny@arbd0.larc.nasa.gov MS-475, Hampton VA, 23681-0001
TCP/IP: ko4lw@ko4lw.ampr.org Packet: ko4lw@n4hog.va.usa
|
|
|
|
|
|
|
Re: Widgets [message #17285 is a reply to message #2717] |
Fri, 01 October 1999 00:00   |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
Robert LeeJoice wrote:
> Question for Widget Gurus: Can I put Widget creation items in an event
> procedure? I want to be able to able to have a menu item open a new window
> that consists of a table to display some data. I have put the following in
> and it seems to work, but I'm concerned about how xmanager sees/doesn't see
> this since the widget statements are not in the "Widget Definition file".
> Is it okay and prudent to do this? I assume as long as there are no
> event_procedures in the code?
Robert,
Anytime you create a new window, the best approach is to create a
separate program to create the widgets in the window and manage events.
For example:
Main program
- Create widgets
- Manage events
- If new window is requested, call new window program
New window program
- Create widgets
- Manage events
Here's an example which creates a simple launcher for XLOADCT, which is
a separate program (see the lib directory in your IDL installation):
;---cut here---
PRO TEST_EVENT, EVENT
;- Get user value from the widget which caused the event
widget_control, event.id, get_uvalue=uvalue
;- Act on the user value
case uvalue of
'Color Table' : xloadct
else : print, 'Unrecognized widget event'
endcase
END
PRO TEST
;- Create widgets
base = widget_base(/column)
butt = widget_button(base, value='Color Table', uvalue='Color Table')
widget_control, base, /realize
;- Manage events
xmanager, 'test', base
END
;---cut here---
In the event handler procedure TEST_EVENT, XLOADCT is called if an event
is received from the 'Color Table' button. XLOADCT is written as a
separate main program so that it can be called from different modes,
such as the command line, or from within a widget program.
Even when you are creating a utility widget which is specific to your
application, it is still much better to code it as a separate IDL
program (like XLOADCT), because you can code and test it as a unit,
separate from the main program.
Cheers,
Liam.
|
|
|
|
|
|
|
|
|
|
Re: Widgets [message #31000 is a reply to message #2717] |
Wed, 29 May 2002 11:24   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Kenneth Mankoff (mankoff@snoe.colorado.edu) writes:
> I am wondering if some widgets exist beyond what I can find in the
> standard IDL library distribution. I would like to add the following
> functionality to my program:
>
> tabbed draw windows. I can see how this could be done quite easily
> with one WIDGET_DRAW (or multiple, each implementation has its own
> pros/cons), and a WIDGET_BUTTON with bitmap for each tab. But maybe
> this exists somewhere and I do not have to write it...
I've seen tabbed draw widgets in an application written by
one of RSI's crack IDL programmers (he might even contact
you privately if they haven't put that code under lock
and key). I guess it wouldn't be impossible to implement
if you have time on your hands and you don't have to worry
about paying the mortgage. Otherwise, I think there are
easier ways to implement multiple window functionality. :-)
> Another widget that would be nice is floating menus (i.e. right-click,
> or shift-click, or whatever anywhere in a WIDGET_DRAW window, and have
> a menu, with sub menus, etc. pop up).
These are called "shortcut" menu widgets and are available
in IDL 5.5.
> Also, I am planning on doing this: Creating hyper-link functionality
> in a WIDGET_TABLE.
Oh. Good luck!
> I am just getting into widget programming.
Well, you will *love* the table widget, then. :-)
> I understand all of the IDL
> widgets, but they are fairly basic. I know of lots of IDL
> libraries. I am looking for a library of compound widgets that I do
> not yet know about. The Coyote library has 4 or 5 (I am using 2), and
> the rest seem to be "widget program examples" more than usable
> "compound widgets"
Teach a man to fish... etc.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: widgets [message #45225 is a reply to message #2717] |
Fri, 19 August 2005 08:02  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
hernan writes:
> Como puedo hacer un widget que sume dos valores?
Como esto:
pro widget_sum_event, event
widget_control, event.top, get_uvalue = info
widget_control, info.text1, get_value=value1
widget_control, info.text2, get_value=value2
value = Float(value1[0]) + Float(value2[0])
widget_control, info.text, set_value = StrTrim(string(value),2)
end
pro widget_sum
;* Ingresamos la base de trabajo.
;* Creamos la primera entrada de datos
base_suma = widget_base(xsize = 300, ysize = 200)
eti1 = widget_label(base_suma, value = 'Ingrese el valor de a: ', $
xsize = 100, xoffset = 20, yoffset = 20)
text1 = widget_text(base_suma, value = '1', uvalue = 'uno', $
xoffset = 120, yoffset = 20, /editable)
;* Creamos la segunda entrada de datos
eti2 = widget_label(base_suma, value = 'Ingrese el valor de b: ', $
xsize = 100, xoffset = 20, yoffset = 60)
text2 = widget_text(base_suma, value = '1', uvalue = 'dos', $
xoffset = 120, yoffset = 60, /editable)
;* Creamos la salida de los datos
eti = widget_label(base_suma, value = 'La suma es: ', $
xsize = 100, xoffset = 20, yoffset = 100)
text = widget_text(base_suma, value = '1', $
xoffset = 120, yoffset = 100, /editable)
widget_control, base_suma, set_uvalue = 'text'
info = {text1:text1, text2:text2, text:text}
widget_control, base_suma, /realize, set_uvalue=info
xmanager, 'widget_sum', base_suma, /no_block
end
Salut,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|