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

Home » Public Forums » archive » Re: updating a different widget from the event handler
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: updating a different widget from the event handler [message #29963 is a reply to message #29957] Tue, 26 March 2002 06:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Higgins (dmh@medphysics.leeds.ac.uk) writes:

> I have set up my first ever GUI and it runs ok. I have a "Browse"
> button and a text widget for a file path. I would like to have the
> file path appear in the text widget after clicking on Browse and
> choosing a file. Getting the path is easy (I named it "newpath"), but
> how to update the text widget (which is called "source") is beyond me.
>
> I tried
> widget_control, source, set_value=newpath
> but the event handler has never heard of "source"...it thinks it's an
> undefined variable. Is there an easy solution?

Ah, well. This is the trick in widget programs, isn't it?
You need to get information which you have over there, over
here where you need it.

The answer is a common block.

No, just kidding. :-)

Typically, we put all the information we need to run our
program in a structure (usually called the "info" structure).
We store that in the user value of the top-level base, since
it is easy to find there (event.top always points to the
top-level base).

info = {source:source, otherthings:otherthings}
Widget_Control, tlb, Set_UValue=info, /No_Copy

You can get the info structure and use it like this:

Widget_Control, event.top, Get_UValue=info, /No_Copy
Widget_Control, info.source, Set_Value=newpath
Widget_Control, event.top, Set_UValue=info, /No_Copy

You can find examples of this in almost any well-written widget
program you find on the Internet.

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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Image scale as 0 - 4096 instead of 0 - 255
Next Topic: Re: color labrynth

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

Current Time: Fri Oct 10 13:40:06 PDT 2025

Total time taken to generate the page: 1.12402 seconds