Tree widget woes [message #37281] |
Fri, 12 December 2003 08:37  |
robert.dimeo
Messages: 42 Registered: November 2001
|
Member |
|
|
Hi,
I work quite a bit with tree widgets in my IDL code and I have run
into a problem. I use tree widgets to represent data in a folder
hierarchy and clicking on the leaves usually results in a plot of a
single data set or a multiple data set depending on whether or not the
user selects more than one leaf. I want to be able to create
dynamically the same kind of folder layout at the root level. If the
multiple keyword is set in the tree widget then I have problems with
where the duplicate folder layout gets realized if one of the leaf
widgets is selected. I tried unselecting the selected leaf widget
prior to adding the folder hierarchy but this does not solve the
problem.
I have found that this problem does not occur on LINUX but only on
WINDOWS. (might be a useful hint there...?)
If the description above does not make sense I hope the code below
will help...
The code at the end of this message illustrates the problems I'm
having. To run it, compile it and type TREE_WIDGET_TEST,MULT = 1.
The keyword MULT simply tells the tree widget to allow multiple
leaf/folder selections. Select one of the leaves (labeled DATA) and
then press the button labeled ADD_FOLDER. What I want to happen is
for a whole new hierarchy of folders to appear at the root level. It
actually appears under the leaf that was selected. Now if you run the
program with the keyword MULT=0 you get the desired behavior.
Unfortunately I want to be able to select multiple files AND be able
to put in the new folder hierarchy. Can I have my cake and eat it
too? Any help would be greatly appreciated.
Thanks,
Rob
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro tt_add_folder,event
file_tree = widget_info(event.top,find_by_uname = 'FILE_TREE')
group = widget_tree(file_tree,value = 'Data Group',/folder,$
/expanded)
leaf1 = widget_tree(group, value = 'Data')
leaf2 = widget_tree(group, value = 'Data')
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro tt_event,event
uname = widget_info(event.id,/uname)
case uname of
'QUIT': widget_control,event.top,/destroy
'ADD_FOLDER': tt_add_folder,event
else:
endcase
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro tree_widget_test,mult = mult
if n_elements(mult) eq 0 then mult = 0
register_name = 'tw_test'
tlb = widget_base(title = 'Tree Widget Test',/col,/tlb_frame_attr)
tree_base = widget_base(tlb,/col)
file_tree = widget_tree(tree_base,multiple = mult,uname = 'FILE_TREE')
group = widget_tree(file_tree,value = 'Data Group',/folder,$
/expanded)
leaf1 = widget_tree(group, value = 'Data')
leaf2 = widget_tree(group, value = 'Data')
void = widget_button(tlb,value = 'ADD FOLDER',uname = 'ADD_FOLDER')
void = widget_button(tlb,value = 'QUIT',uname = 'QUIT')
widget_control,tlb,/realize
xmanager,register_name,tlb,/no_block,event_handler = 'tt_event'
end
|
|
|