|
Re: Generating a widget 'event' from an external program... [message #64364 is a reply to message #64359] |
Thu, 18 December 2008 03:27  |
Allan Whiteford
Messages: 117 Registered: June 2006
|
Senior Member |
|
|
George,
ghgm2008@gmail.com wrote:
> Hi there,
>
> I have a well developed widget program (which actually shows data
> projected on an Earth globe) and I am wanting the program to respond
> to a 'button push' generated by an external program. Specifically I
> want the program to update in real-time.
>
> I'm sure there are many ways of doing such a thing - but one way that
> would work for me right now would be if an external program (like a
> 'cron driven' perl script) could 'push' an idl widget button.
>
Look at X11::GUITest but it can get a bit messy to locate the window
etc. I tend to only use X11::GUITest to simulate the keyboard but I
think it can also simulate a mouse.
You could also look at signals but I've never done this with IDL so I
don't know how easy/possible it is.
> Is there any way of doing this ? If not (in the way I am imagining
> it) then the supplementary question is:
> How do you build a full widget program that will do all the usual
> widget things - but will also just naturally update itself every
> minute or so...
>
Look at the timer= keyword to widget_control.
As an example:
pro time_e,event
widget_control,event.top,get_uvalue=wid
widget_control,wid,set_value=systime()
widget_control,wid,timer=1 ; second
end
pro time_w
tlb=widget_base(title='Time')
label=widget_label(tlb,value=systime())
widget_control,tlb,/realize
widget_control,label,timer=1 ; second
widget_control,tlb,set_uvalue=label
xmanager,'time_w',tlb,event_handler='time_e'
end
Note in particular that you need to re-set the timer after it's
happened. Also, it's not necessary to associate the timer with the label
(typically it would be for the top widget_base), I was just being lazy.
Thanks,
Allan
> Thanks for any help....
>
> George.
|
|
|