[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Menu Value and UValue



"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