Re: dialog_pickfile return question.. [message #54314] |
Wed, 06 June 2007 09:51  |
ryanselk
Messages: 16 Registered: May 2007
|
Junior Member |
|
|
On Jun 6, 10:13 am, jkj <k...@vexona.com> wrote:
> On Jun 6, 10:44 am, ryans...@gmail.com wrote:
>
>
>
>> How would I go about getting the path choosen from Dialog Pickfile and
>> then having that path appear in a pre-existing widget_text? I have
>> attempted using a pointer but I could not get it to work, as the
>> widget_text doesn't 'update'.
>
>> Here is my code, if anyone could help it would be fantastic!
>
>> PRO test_event, ev
>> widget_control, ev.id, get_value=value
>> widget_control, ev.top, get_uvalue=info
>
>> if value eq '...' then begin
>> filepicked = DIALOG_PICKFILE (/READ)
>> print, "File picked"
>> print, filepicked
>> fp = ptr_new(filepicked)
>> END
>
>> END
>
>> PRO test, value
>
>> main = widget_base (title='PRO', MBAR=bar, /row)
>> wt0 = WIDGET_TEXT(main, XSIZE=15, uvalue='Filename', /ALL_EVENTS, /
>> EDITABLE)
>
>> findfiles = widget_button (main, value='...')
>
>> widget_control, main, /realize
>> widget_control, main, set_uvalue=info
>> xmanager, 'experiment', main
>
>> END
>
>> Thanks,
>> Ryan
>
> Sent the id of widget_text to the handler in the info structure and
> then update it from within the event handler:
>
> 1. Add wt0 to the info structure:
> info = { $
> id:wt0 $
> }
>
> ....
> 2. use wt0 in the event handler:
> filepicked = DIALOG_PICKFILE (/READ)
> widget_control, info.id, set_value=filepicked
>
> -Kevin
Thank you to the both of you!
I got it working great now.
I know my code there has some problems, that was just a small part of
a bigger program
I used to make showing you guys easier.
Thanks again!
|
|
|
Re: dialog_pickfile return question.. [message #54315 is a reply to message #54314] |
Wed, 06 June 2007 09:13   |
jkj
Messages: 48 Registered: April 2007
|
Member |
|
|
On Jun 6, 10:44 am, ryans...@gmail.com wrote:
> How would I go about getting the path choosen from Dialog Pickfile and
> then having that path appear in a pre-existing widget_text? I have
> attempted using a pointer but I could not get it to work, as the
> widget_text doesn't 'update'.
>
> Here is my code, if anyone could help it would be fantastic!
>
> PRO test_event, ev
> widget_control, ev.id, get_value=value
> widget_control, ev.top, get_uvalue=info
>
> if value eq '...' then begin
> filepicked = DIALOG_PICKFILE (/READ)
> print, "File picked"
> print, filepicked
> fp = ptr_new(filepicked)
> END
>
> END
>
> PRO test, value
>
> main = widget_base (title='PRO', MBAR=bar, /row)
> wt0 = WIDGET_TEXT(main, XSIZE=15, uvalue='Filename', /ALL_EVENTS, /
> EDITABLE)
>
> findfiles = widget_button (main, value='...')
>
> widget_control, main, /realize
> widget_control, main, set_uvalue=info
> xmanager, 'experiment', main
>
> END
>
> Thanks,
> Ryan
Sent the id of widget_text to the handler in the info structure and
then update it from within the event handler:
1. Add wt0 to the info structure:
info = { $
id:wt0 $
}
....
2. use wt0 in the event handler:
filepicked = DIALOG_PICKFILE (/READ)
widget_control, info.id, set_value=filepicked
-Kevin
|
|
|
Re: dialog_pickfile return question.. [message #54316 is a reply to message #54315] |
Wed, 06 June 2007 09:08   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
ryanselk@gmail.com writes:
> How would I go about getting the path choosen from Dialog Pickfile and
> then having that path appear in a pre-existing widget_text? I have
> attempted using a pointer but I could not get it to work, as the
> widget_text doesn't 'update'.
You have several problems, but here is a quick and dirty job
that at least solves this one:
PRO test_event, ev
widget_control, ev.id, get_value=value
widget_control, ev.top, get_uvalue=info
if value eq '...' then begin
filepicked = DIALOG_PICKFILE (/READ)
if filepicked eq "" then return
print, "File picked"
print, filepicked
filename = file_basename(filepicked)
widget_control, info.wt0, set_value=filename
fp = ptr_new(filepicked)
END
END
PRO test, value
main = widget_base (title='PRO', MBAR=bar, /row)
wt0 = WIDGET_TEXT(main, XSIZE=15, /EDITABLE)
findfiles = widget_button (main, value='...')
widget_control, main, /realize
info = {wt0:wt0}
widget_control, main, set_uvalue=info
xmanager, 'test', main
END
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.")
|
|
|
Re: dialog_pickfile return question.. [message #54430 is a reply to message #54314] |
Sat, 09 June 2007 04:17  |
pook41
Messages: 16 Registered: January 2007
|
Junior Member |
|
|
On Jun 7, 1:51 am, ryans...@gmail.com wrote:
> On Jun 6, 10:13 am, jkj <k...@vexona.com> wrote:
>
>
>
>> On Jun 6, 10:44 am, ryans...@gmail.com wrote:
>
>>> How would I go about getting the path choosen from Dialog Pickfile and
>>> then having that path appear in a pre-existing widget_text? I have
>>> attempted using a pointer but I could not get it to work, as the
>>> widget_text doesn't 'update'.
>
>>> Here is my code, if anyone could help it would be fantastic!
>
>>> PRO test_event, ev
>>> widget_control, ev.id, get_value=value
>>> widget_control, ev.top, get_uvalue=info
>
>>> if value eq '...' then begin
>>> filepicked = DIALOG_PICKFILE (/READ)
>>> print, "File picked"
>>> print, filepicked
>>> fp = ptr_new(filepicked)
>>> END
>
>>> END
>
>>> PRO test, value
>
>>> main = widget_base (title='PRO', MBAR=bar, /row)
>>> wt0 = WIDGET_TEXT(main, XSIZE=15, uvalue='Filename', /ALL_EVENTS, /
>>> EDITABLE)
>
>>> findfiles = widget_button (main, value='...')
>
>>> widget_control, main, /realize
>>> widget_control, main, set_uvalue=info
>>> xmanager, 'experiment', main
>
>>> END
>
>>> Thanks,
>>> Ryan
>
>> Sent the id of widget_text to the handler in the info structure and
>> then update it from within the event handler:
>
>> 1. Add wt0 to the info structure:
>> info = { $
>> id:wt0 $
>> }
>
>> ....
>> 2. use wt0 in the event handler:
>> filepicked = DIALOG_PICKFILE (/READ)
>> widget_control, info.id, set_value=filepicked
>
>> -Kevin
>
> Thank you to the both of you!
> I got it working great now.
>
> I know my code there has some problems, that was just a small part of
> a bigger program
> I used to make showing you guys easier.
>
> Thanks again!
Dialog_pickfile has the GET_PATH keyword which would seem to be what
you want.
Andrew
|
|
|