Re: Widgets: group leader and procedures [message #37540 is a reply to message #37520] |
Sun, 04 January 2004 07:26   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Karthik writes:
> I have a main programme with a widget base and it includes a widget
> button called "Alalyse Data" - when the user clicks on it I would like
> to execute the bit of code called "alalyse_simset_data", so the thing
> looks like this (not exactly the same but the code below is illustrative)
>
> ;-----------------------------------------
> Pro main_programme
> tlb = widget_base()
> analyse = widget_button(row5, value = 'Analyse Data', $
> Event_PRO= 'analyse_simset_data')
> <etc>
> widget_control, tlb, /realize
>
> state={ bunch of stuff}
> pstate = Ptr_new(state, /no_copy)
> widget_control, tlb, set_uvalue = pstate
> xmanager, 'make_random_activity', tlb
> END
> ;-----------------------------------------
>
>
> Now I would like, for clarity, the analyse_simset_data bit of code to be
> a completely independent file and I would like that to contain a widget
> as well.
>
> ;-----------------------------------------
> PRO analyse_simset_data, event
> widget_control, event.top, get_uvalue = pstate
>
> base2=widget_base( ?????????? )
> END
> ;-----------------------------------------
>
>
> The ????? marks refer to my doubts on the subject: how do you pass on
> the group leader information in the state pointer so that killing the
> main widget from main_programme kills the widget created in
> analyse_simset_data as well? Is the group leader information a string?
> Are there any rules I should follow when a procedure invoked my a main
> programme creates a widget? Any advice/suggestion would be greatly
> appreciated.
You could simply store the group leader ID in the state structure
so you could retrieve it and use it when you create your second
top-level base, but this is not usually necessary. Almost always
the new group leader is either event.top or event.id. In your
case, event.top will do (although you could use either, the group
leader widget does not have to be a base widget):
base2=widget_base(group_leader=event.top, ..._
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
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
|
|
|