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

Home » Public Forums » archive » auto-managed compound widgets
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
auto-managed compound widgets [message #54372] Fri, 01 June 2007 13:09
David R is currently offline  David R
Messages: 1
Registered: June 2007
Junior Member
I was attempting to make a simple file selection compound widget that
works with auto_wid_mng, but could not find any documentation on what
functions need to be added for this to work. I could also not find any
compound widget source online that accomplished this either. Is it
possible for user widgets to be auto-managed? As a reference to what I
am attempting, below is my code so far. It is supposed to appear like
widget_outf, except with more customizable prompts.

;Test procedure:
pro widgettest
base = widget_auto_base(title = 'base1')
widgets = widget_base(base,row=2)
templabel=
widget_string(widgets,prompt='test',uvalue='templabel',defau lt='test',/
auto) ;to make automanagement work
wid = widget_fsel(widgets,label='Header file: ',prompt='Input
file',uvalue='fsel',xsize=50)
result=auto_wid_mng(base)
help, result,/struct ;view result
end

pro widget_fsel_event,ev
;base = WIDGET_INFO(ev.HANDLER,/parent)
WIDGET_CONTROL, ev.HANDLER, GET_UVALUE=state
IF (ev.ID EQ state.btn) THEN BEGIN
sel = dialog_pickfile(title =
state.prompt,directory=state.directory)
if (strcmp(sel,'') eq 0) then begin
sel = STRJOIN(STRSPLIT(sel,'\\', /EXTRACT), '/')
if (state.directory) AND (strcmp(strmid(sel,strlen(sel)-1,1), '/')
eq 0) then sel = sel+'/'
widget_control, state.field,set_value=sel
end
end
end
;get value function
function widget_fsel_get_value, id
handlebase = widget_info(id,/child)
widget_control,handlebase,get_uvalue=state
widget_control,state.field,get_value=val
return, val ;return text in field widget
end

function widget_fsel, parent,frame=frame,uvalue=uvalue,label=label,$
default=default, prompt=prompt,xsize=xsize, directory=directory
;parent = base widget for this compound widget to be located in
;label = text label display
;prompt = prompt when selecting files
;xsize = size of textbox containing file path
;default= default answer
;
;set defaults if empty
if (n_params() eq 0) then parent = widget_base()
if (n_elements(label)eq 0) then label = ''
if (n_elements(default)eq 0) then default = ''
if (n_elements(prompt)eq 0) then prompt = 'Select file:'
if (n_elements(directory)eq 0) then directory=0
;
base = widget_base(parent,frame=frame)
handlebase = widget_base(base,row=1)
textlabel = widget_label(handlebase,value=label,units=0)
btn = widget_button(handlebase, value = 'Choose',xsize=50)
field = widget_text(handlebase, value = default,xsize=xsize,/editable)
state = {prompt:prompt, btn:btn, field:field, directory:directory}
widget_control, handlebase, SET_UVALUE=state, /REALIZE
widget_control, base, set_uvalue = uvalue, func_get_value =
'widget_fsel_get_value'
xmanager, 'widget_fsel',handlebase, /no_block

return, base
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: get image from widget_draw
Next Topic: Iplot x labeling

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

Current Time: Wed Oct 08 15:39:14 PDT 2025

Total time taken to generate the page: 0.00468 seconds