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

Home » Public Forums » archive » Re: Menu Value and UValue
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Menu Value and UValue [message #25098] Thu, 17 May 2001 14:54
Mark Guagenti is currently offline  Mark Guagenti
Messages: 14
Registered: May 2000
Junior Member
Thanks for the help I didn't think it could be done until I saw your script. It
ended up that I was writing the same value back into it's orginal spot instead of
moving it down. What was I thinking! :)
Mark

Dave Greenwood wrote:

> "Mark Guagenti" <guagenti@foodsci.purdue.edu> wrote:
>> Hello again!
>> I am trying to add a feature into an IDL program that lists the last 4 files
>> opened. The last 4 files will be displayed as a part of the "file" menu on
>> my program. I've been trying to change the "Value" and "UValue" of a
>> Widget_Button that is apart of a menu. From what I am seeing it can't be
>> done. I don't get an error from IDL or anything when I execute something
>> like
>> Widget_Control, widgetid, Set_Value=lastfile1, Set_UValue=lastfile1
>> But when you go look at the menu nothing has changed from when it was first
>> realized when the program was launched. The old values are still there but
>> this time if you select that menu option nothing happens where it used to do
>> what it was supposed to do.
>
> What version and os? Are you sure you have the correct widgetid? The
> following program seems to do what I think you want to do. Tested on
> IDL5.3 on VMS and WNT.
>
> =================
> PRO New_files, ev
> widget_control, ev.top, get_uvalue=ptr
> (*ptr).fnum = (*ptr).fnum + 1
> for i=0,3 do begin
> fname = 'File_' + StrCompress(String((*ptr).fnum+i),/Remove_all)
> Widget_Control, (*ptr).ids[i], Set_Uvalue=fname, Set_Value=fname
> endfor
> END
>
> PRO Button_Push, ev
> widget_control, ev.id, get_Uvalue=fname
> Print,'Button for ',fname,' pushed'
> END
>
> PRO T_Exit, ev
> Widget_Control, ev.top, /Destroy
> END
>
> PRO T
> T_base = Widget_Base( MBar=menuBase, TITLE='The Test', xsize=200, ysize=100)
> fileID = Widget_Button(menubase, Value='File')
> dummy = Widget_Button(fileID, Value='New Files', Event_Pro='New_files')
> dummy = Widget_Button(fileID, /Separator, Value='Exit', Event_Pro='T_Exit')
> ids = lindgen(4)
> sep = 1
> for i=0L, 3 do begin
> fname = 'File_' + StrCompress(String(i),/Remove_all)
> ids[i] = Widget_Button( fileId, Separator=sep, Uvalue=fname, $
> Value=fname, Event_Pro='Button_Push' )
> sep = 0
> endfor
>
> info = {fnum: 0L, ids: ids}
> infoPtr = Ptr_New(info, /No_Copy)
>
> WIDGET_CONTROL, T_Base, SET_UVALUE=infoPtr, /realize
> XManager, 'T_base', T_base, /NO_BLOCK
> end
> =================
>
> Dave
> --------------
> Dave Greenwood Email: Greenwoodde@ORNL.GOV
> Oak Ridge National Lab %STD-W-DISCLAIMER, I only speak for myself
Re: Menu Value and UValue [message #25100 is a reply to message #25098] Thu, 17 May 2001 11:49 Go to previous message
Dave Greenwood is currently offline  Dave Greenwood
Messages: 33
Registered: October 2000
Member
"Mark Guagenti" <guagenti@foodsci.purdue.edu> wrote:
> Hello again!
> I am trying to add a feature into an IDL program that lists the last 4 files
> opened. The last 4 files will be displayed as a part of the "file" menu on
> my program. I've been trying to change the "Value" and "UValue" of a
> Widget_Button that is apart of a menu. From what I am seeing it can't be
> done. I don't get an error from IDL or anything when I execute something
> like
> Widget_Control, widgetid, Set_Value=lastfile1, Set_UValue=lastfile1
> But when you go look at the menu nothing has changed from when it was first
> realized when the program was launched. The old values are still there but
> this time if you select that menu option nothing happens where it used to do
> what it was supposed to do.

What version and os? Are you sure you have the correct widgetid? The
following program seems to do what I think you want to do. Tested on
IDL5.3 on VMS and WNT.

=================
PRO New_files, ev
widget_control, ev.top, get_uvalue=ptr
(*ptr).fnum = (*ptr).fnum + 1
for i=0,3 do begin
fname = 'File_' + StrCompress(String((*ptr).fnum+i),/Remove_all)
Widget_Control, (*ptr).ids[i], Set_Uvalue=fname, Set_Value=fname
endfor
END

PRO Button_Push, ev
widget_control, ev.id, get_Uvalue=fname
Print,'Button for ',fname,' pushed'
END

PRO T_Exit, ev
Widget_Control, ev.top, /Destroy
END

PRO T
T_base = Widget_Base( MBar=menuBase, TITLE='The Test', xsize=200, ysize=100)
fileID = Widget_Button(menubase, Value='File')
dummy = Widget_Button(fileID, Value='New Files', Event_Pro='New_files')
dummy = Widget_Button(fileID, /Separator, Value='Exit', Event_Pro='T_Exit')
ids = lindgen(4)
sep = 1
for i=0L, 3 do begin
fname = 'File_' + StrCompress(String(i),/Remove_all)
ids[i] = Widget_Button( fileId, Separator=sep, Uvalue=fname, $
Value=fname, Event_Pro='Button_Push' )
sep = 0
endfor

info = {fnum: 0L, ids: ids}
infoPtr = Ptr_New(info, /No_Copy)

WIDGET_CONTROL, T_Base, SET_UVALUE=infoPtr, /realize
XManager, 'T_base', T_base, /NO_BLOCK
end
=================

Dave
--------------
Dave Greenwood Email: Greenwoodde@ORNL.GOV
Oak Ridge National Lab %STD-W-DISCLAIMER, I only speak for myself
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: busted (was Re: floor() function definition)
Next Topic: re:call_external with V c++

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

Current Time: Wed Oct 08 15:21:56 PDT 2025

Total time taken to generate the page: 0.00549 seconds