PDA

View Full Version : Widget help



green12
02-16-2009, 11:17 AM
can someone help me get the value of my file section to be displayed in the 'text' field after selection? I assume I use WwSetValue but I can never get it. Thank you. :)

PRO GUI
top=WwInit('Optical_Mapping', 'Examples', layout, /Vertical, Spacing=5, Border=3)
label=WwText(layout, /Label, Text='This is Label')
text=WwText(layout, 'TextCB', Cols=40, left=label)
btn1=WwButtonBox(layout,'Browse', 'fileSearchCB', left=text)
status=WwSetValue(top, /Display)
WwLoop
END
;************************************************* ********************************
PRO fileSearchCB, wid, data
file = WwFileSelection(wid,'fileOK', 'fileCancel', Title='Browse')
END

PRO fileOK, wid, shell
value = WwGetValue(wid)
status = WwSetValue(shell, /Close)
END

PRO fileCancel, wid, shell
PRINT, 'File Cancel'
END

donb
02-16-2009, 12:02 PM
Hi green12,

In order to set the value of the text field, you need the widget ID of the text widget, and then you need to set the value of that widget after you have the filename from the file selection widget.

You can either use COMMON blocks to pass widget IDs between routines (callbacks), or you can use the Userdata keywords. Below is a modified version of your code that uses COMMON blocks, and hopefully accomplishes what you're trying to do.

Cheers, Don B.


;*************************************************
PRO fileSearchCB, wid, data
file = WwFileSelection(wid,'fileOK', 'fileCancel', Title='Browse')
END

PRO fileOK, wid, shell
common gui_ids, text ;;; added the common here so this callback
;;; has access to the widget id we want to update
value = WwGetValue(wid)
status = WwSetValue(shell, /Close)
status = WwSetValue(text, value) ;;; set the widget value (the filename)
;;; into the text widget
END

PRO fileCancel, wid, shell
PRINT, 'File Cancel'
END

PRO GUI
common gui_ids, text ;;; added this commom to get the text widget id
top=WwInit('Optical_Mapping', 'Examples', layout, /Vertical, Spacing=5, Border=3)
label=WwText(layout, /Label, Text='This is Label')
text=WwText(layout, 'TextCB', Cols=40, left=label)
btn1=WwButtonBox(layout,'Browse', 'fileSearchCB', left=text)
status=WwSetValue(top, /Display)
WwLoop
END

green12
02-18-2009, 12:07 PM
Thank you, that did work!

Does the wid parameter automatically send through functions? I don't see how that parameter is passed between CBs.