Re: Widgets: group leader and procedures [message #37541 is a reply to message #37540] |
Sun, 04 January 2004 04:45  |
Robert Moss
Messages: 74 Registered: February 1996
|
Member |
|
|
In the case you have described, you can simply use event.top as the
group leader for the new top level base. Here event.top is the tlb
created in your main procedure.
;-----------------------------------------
PRO analyse_simset_data, event
widget_control, event.top, get_uvalue = pstate
base2=widget_base( title = 'Simset Analysis', $
group_leader = event.top )
<...etc...>
END
;-----------------------------------------
A bit of unsolicited advice: you had the following:
state={ bunch of stuff}
pstate = Ptr_new(state, /no_copy)
widget_control, tlb, set_uvalue = pstate
I would do this instead:
state = {bunch of stuff}
widget_control, tlb, set_uvalue = state, /no_copy
There is no real need to stuff your entire widget state into a pointer.
If you have dynamic data structure elements or large array elements in
the state, make those individual elements pointers, but not the entire
state structure. This will save you from typing a lot of extra
asterisks when you access the state later. Your mileage may vary.
Batteries not included. May contain nuts.
Robert Moss, PhD
Karthik wrote:
> Hello All,
>
> 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.
>
> Thanks,
>
> Karthik.
>
|
|
|