comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » WIDGETS
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Widgets [message #17285 is a reply to message #2717] Fri, 01 October 1999 00:00 Go to previous messageGo to previous message
Liam Gumley is currently offline  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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: widgets
Next Topic: Sort without loops

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 07:07:40 PDT 2025

Total time taken to generate the page: 0.94573 seconds