dynamically change the layout of widget [message #38527] |
Wed, 17 March 2004 08:25  |
Tianle Yuan
Messages: 5 Registered: March 2004
|
Junior Member |
|
|
Hi,there
Here's my question: I have set up a widget base and layout. There's a
button,But_A, in that widget base. For it,I creat a event handler, pro_A.
What I'm wishing to do is when I click the button and the event handler is
called, I will create another widget in the widget base I set up before.
How can I realize it ,or is it possible?
Thanks a lot.
|
|
|
Re: dynamically change the layout of widget [message #38655 is a reply to message #38527] |
Thu, 18 March 2004 05:24  |
robert.dimeo
Messages: 42 Registered: November 2001
|
Member |
|
|
Try this...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro ev_handler,event
uname = widget_info(event.id,/uname)
case uname of
'button_1': $
begin
but_b = widget_button(event.top, $
value = 'Now Press Me', $
uname = 'button_2')
end
'button_2': $
begin
widget_control,event.id,/destroy
end
'quit': widget_control,event.top,/destroy
else:
endcase
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro dynamic_widget
tlb = widget_base(/col,/tlb_frame_attr)
but_a = widget_button(tlb,value = 'Press Me', $
uname = 'button_1')
quit_button = widget_button(tlb,value = 'Quit', $
uname = 'quit')
widget_control,tlb,/realize
xmanager,'dynamic_widget',tlb,/no_block, $
event_handler = 'ev_handler'
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hope this helps,
Rob
Tianle Yuan <tianle@rac3.wam.umd.edu> wrote in message news:<c39u52$spn$1@grapevine.wam.umd.edu>...
> Hi,there
>
> Here's my question: I have set up a widget base and layout. There's a
>
> button,But_A, in that widget base. For it,I creat a event handler, pro_A.
>
> What I'm wishing to do is when I click the button and the event handler is
>
> called, I will create another widget in the widget base I set up before.
>
> How can I realize it ,or is it possible?
>
> Thanks a lot.
|
|
|
Re: dynamically change the layout of widget [message #38661 is a reply to message #38527] |
Wed, 17 March 2004 16:39  |
andrew.cool
Messages: 47 Registered: July 2003
|
Member |
|
|
Tianle Yuan <tianle@rac3.wam.umd.edu> wrote in message news:<c39u52$spn$1@grapevine.wam.umd.edu>...
> Hi,there
>
> Here's my question: I have set up a widget base and layout. There's a
>
> button,But_A, in that widget base. For it,I creat a event handler, pro_A.
>
> What I'm wishing to do is when I click the button and the event handler is
>
> called, I will create another widget in the widget base I set up before.
>
> How can I realize it ,or is it possible?
>
> Thanks a lot.
Depending on exactly what it is that you're trying to do, it might be easier to
simply create the "other widget" in your main code, but not map it to the
screen, by setting MAP=0. Then when you click But_A, you do a
widget_control, other_widget_id,MAP=1. How you carry around the widget id
for the other_widget, well there's all sorts of ways ranging from the sinful
to the cursed, to the beatified. But pick one that works for you.
Perhaps what you really want to do is have the other widget visible all
the time, but de-sensitised until you hit But_A? In which case you want
something like Widget_Control,other_widget_id,Sensitive=1
Andrew
DSTO, Adelaide, South Australia
|
|
|