|
Re: Widget [message #39433 is a reply to message #22367] |
Tue, 18 May 2004 16:36   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Anand writes:
> Can anyone help me out with IDL widgets. I created a widget to
> display the image and from there I opened one more image to show a
> region in that image in a different widget. After I close the new
> widget my old widget does not seem to be my current graphic window.
> So when I try to perform some mouse commands it by default open a new
> IDL window. Can some one tell me how do I make my old widget the
> current graphic window after I close the current widget. I used
> widget_control, ev.top,/destroy, to detroy the top widget.
Oh, dear. :-(
You might have a look at ZIMAGE. It might even do exactly
what you are trying to do. You *definitely* need to know
what window is the current graphics window (the one you
will be drawing into) in a widget program. You do it
by doing a WSET to the window index number. This number
is the *value* of the draw widget:
Widget_Control, drawWidgetID, Get_Value=wid
WSet, wid
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
|
Re: widget [message #77813 is a reply to message #22367] |
Fri, 07 October 2011 14:14  |
Marco Otto
Messages: 2 Registered: October 2011
|
Junior Member |
|
|
Thank you Mike,
that was fast, "pitiful" enough and more over very help full!!!
Best regards
Marco
PS: I will definitely read more books in the future - even some on
IDL :-)
|
|
|
Re: widget [message #77814 is a reply to message #22367] |
Fri, 07 October 2011 12:47  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 10/7/11 1:11 PM, David Fanning wrote:
> Marco Otto writes:
>
>> I am new to widget programming in IDL :-(
>>
>> maybe someone can tell me how to realise the second step:
>>
>> 1. read a .sav file
>> 2. if there are more than one variable stored then give me a list of
>> variables (here comes the widget - hence the hard part for me) where I
>> can interactively select the variable I want to be read into IDL
>> 3. rename the variable
>>
>> That's all! But somehow I don't get it - seems a bit over complicated
>> in IDL - but the problem is definitely sitting in front of the
>> screen ;-)
>>
>> Here is what I have so far
>
> Oh, dear! I'm off to Australia in a few hours, so I
> won't be able to help. But, I will tell you that
> nearly everything about this program is wrong. :-)
>
> Ben Tupper, or someone else, may take pity on you. Or,
> I'll give you some help when I get back. But, just
> briefly, I think you want to use the IDL_Savefile
> object to query your save file and get the variable
> names, and I *think* (can't really tell for sure)
> you want to build a pop-up dialog widget:
>
> http://www.idlcoyote.com/widget_tips/popup.html
Try the program listed below; it's not hard to write, but the
explanation would be (MUCH) longer than the program. For a full
explanation, I would see one of the fine books available to learn IDL
(http://www.ittvis.com/language/en-US/Support/IDLBooks.aspx). To try it, do:
IDL> a = 1
IDL> b = 2
IDL> c = 3
IDL> save, a, b, c, filename='test.sav'
IDL> mg_sav_selection, 'test.sav'
The user interface is pretty simple: change the test in the text box at
the bottom to the name you want to call the variable and then select the
variable you want to import from the list.
pro mg_sav_selection_event, event
compile_opt strictarr
on_error, 2
widget_control, event.top, get_uvalue=pstate
uname = widget_info(event.id, /uname)
case uname of
'var_list': begin
varname_text = widget_info(event.top, find_by_uname='varname_text')
widget_control, varname_text, get_value=varname
(*pstate).s->restore, ((*pstate).varnames)[event.index]
(scope_varfetch(varname, /enter, level=1)) $
= scope_varfetch(((*pstate).varnames)[event.index])
end
'varname_text': ; no need to do anything
else: message, 'unknown widget event'
endcase
end
pro mg_sav_selection_cleanup, tlb
compile_opt strictarr
widget_control, tlb, get_uvalue=pstate
obj_destroy, (*pstate).s
ptr_free, pstate
end
pro mg_sav_selection, sav_filename
compile_opt strictarr
s = obj_new('IDL_Savefile', sav_filename)
varnames = s->names(count=nvars)
if (nvars eq 0L) then return
tlb = widget_base(/column, title='Select variables from ' + sav_filename)
var_list = widget_list(tlb, value=varnames, xsize=20, ysize=10, $
uname='var_list')
varname_text = widget_text(tlb, value='varname', xsize=20, /editable, $
uname='varname_text')
widget_control, tlb, /realize
state = { s: s, varnames: varnames }
pstate = ptr_new(state, /no_copy)
widget_control, tlb, set_uvalue=pstate
xmanager, 'mg_sav_selection', tlb, /no_block, $
event_handler='mg_sav_selection_event', $
cleanup='mg_sav_selection_cleanup'
end
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
|
|
|
Re: widget [message #77815 is a reply to message #22367] |
Fri, 07 October 2011 12:11  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Marco Otto writes:
> I am new to widget programming in IDL :-(
>
> maybe someone can tell me how to realise the second step:
>
> 1. read a .sav file
> 2. if there are more than one variable stored then give me a list of
> variables (here comes the widget - hence the hard part for me) where I
> can interactively select the variable I want to be read into IDL
> 3. rename the variable
>
> That's all! But somehow I don't get it - seems a bit over complicated
> in IDL - but the problem is definitely sitting in front of the
> screen ;-)
>
> Here is what I have so far
Oh, dear! I'm off to Australia in a few hours, so I
won't be able to help. But, I will tell you that
nearly everything about this program is wrong. :-)
Ben Tupper, or someone else, may take pity on you. Or,
I'll give you some help when I get back. But, just
briefly, I think you want to use the IDL_Savefile
object to query your save file and get the variable
names, and I *think* (can't really tell for sure)
you want to build a pop-up dialog widget:
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.")
|
|
|