Re: widget event structure doesn't transfer [message #81138 is a reply to message #81051] |
Tue, 14 August 2012 14:30   |
Oana Coman
Messages: 27 Registered: December 2011
|
Junior Member |
|
|
Hi,
I have the book and it's definitely my go-to widget guide. I have a bit of an idea how to run normal widgets using procedures but once I try to figure out the functions and these popup dialogs it's like a whole new ballgame (I am also a little slow haha so I'm sure that doesn't help). I've looked at the Pop-up Dialog page a lot and though I get the overall idea, I'm not sure how to carry it out.
For example, textbox is defined:
FUNCTION TextBox, Title=title, Label=label, Cancel=cancel, $
Group_Leader=groupleader, XSize=xsize, Value=value
but if I want it to launch when i click a button, the code (and i'm assuming this is how i would call it):
w_userRoi= widget_button(p,value = 'Get User Defined ROI',frame = 2,$
event_func = 'textbox')
wouldn't have anywhere to input the various arguments. How would I put those in the function? (i tried taking them all out and calling it that way, but I'm still getting an "incorrect number of arguments" error"). But either way, I do want to have at least one argument.
Also, do I even need all those? All I want the function to use is the uservalues of the original widget (since I want to do stuff with those), and I guess the Cancel variable. But then there's the issue of not knowing how to call the function correctly.
Finally, where does my return value save to? Would it be w_userRoi, or somewhere else?
Thanks for the help.
On Tuesday, August 14, 2012 6:22:29 AM UTC-7, David Fanning wrote:
> Kat writes:
>
>
>
>> When I try to call my userROI data in widget 1, I get:
>
>> % WIDGET_CONTROL: Invalid widget identifier: 143.
>
>>
>
>>
>
>> Do you have any thoughts on this? Where did I go wrong?
>
>
>
> Well, it appears you have gone wrong almost from the get-go. :-)
>
>
>
> Mostly what I think you need to know is that IDL doesn't
>
> suspend it's rules about local variables being protected
>
> inside of procedures and functions just because you are
>
> writing a widget program. Widget identifiers are local
>
> variables. (This is your immediate problem, but there
>
> are many others, too.)
>
>
>
> You might want to read up on widget programming a bit.
>
> IDL Programming Techniques is *very* old and outdated,
>
> but the widget section is still pretty good. If you
>
> could find a copy of that, it would help you a great
>
> deal, I think.
>
>
>
> If you want to call a second widget program to provide
>
> information to the first, we call that a "pop-up" or
>
> "dialog" widget. It is written as a function that returns
>
> data (usually in the form of a structure) to the calling
>
> program. You can read more about how to write it here:
>
>
>
> http://www.idlcoyote.com/widget_tips/popup.html
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|