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

Home » Public Forums » archive » event_pro for compound widgets
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: EVENT_PRO [message #73774 is a reply to message #40935] Mon, 29 November 2010 09:22 Go to previous messageGo to previous message
silje is currently offline  silje
Messages: 4
Registered: October 2010
Junior Member
On 29 Nov, 17:46, David Fanning <n...@dfanning.com> wrote:
> silje writes:
>
>> Hey, I'm trying to structure my IDL program into several event
>> handlers, e.g. one procedure that opens a file, one that save data
>> etc. To do this I have used EVENT_PRO like this:
>
>> PRO MotionControl
>
>> tlb = WIDGET_BASE(column=1, title='MotionControl', tlb_frame_attr=1,
>> MBAR=bar )
>>   file_menu = WIDGET_BUTTON(bar, VALUE='File', /MENU)
>>   file_bttn1 = WIDGET_BUTTON(file_menu, VALUE='Open dataset',
>> UVALUE='OpenDat', EVENT_PRO = 'OpenData')
>>   file_bttn2 = WIDGET_BUTTON(file_menu, VALUE='Save dataset',
>> UVALUE='SaveDat', EVENT_PRO = 'SaveData')
>
>> ............................................................ ..........................
>> etc
>
>> WIDGET_CONTROL, tlb, /realize
>> XMANAGER, 'MotionControl', tlb
>
>> end
>
>> In this way I have one event handler  that is called
>> MotionControl_event that takes care of all the events not handled by
>> specified EVENT_PRO. I don't know if this is a really bad way of
>> structuring my code, even though it does work. Can somebody give me
>> some tips?
>
> It is a perfectly OK way to structure your code,
> although you will get in trouble sooner or later
> with the names of these routines. I would read the
> "How to Name Files" article again. :-)
>
>   http://www.dfanning.com/tips/namefiles.html
>
> These event handlers should have names like
> "MotionControl_SaveData" and "MotionControl_OpenData".
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")


Changing the names to something more meaningful shouldn't be any
problem :) But it still feels like an easy solution. I also found this
in a previous discussion

"If you do use EVENT_PRO to assign an event handler for a top-level
base being directly managed by XMANAGER, you will find exceedingly
strange things going on in your widget program, if it works at all.
Believe me, you don't want to do this. "

http://www.dfanning.com/widget_tips/multiple_widgets.html

Could you explain what you meant by that?

Silje
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: EVENT_PRO
Next Topic: Notable Coyote Program Updates

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

Current Time: Wed Oct 08 17:58:33 PDT 2025

Total time taken to generate the page: 0.00391 seconds