tcl - traversing a ttk::treeview in Tk -


is there simple way traverse items of tcl/tk ttk::treview if items in listbox? example:

                          |   |-- b     visit  |   |   |-- c     order  |   |   |-- d         ---->    b c d e f g            |   e            v   |-- f                    |-- g 

i understand correspond traversing tree in preorder , is, in fact, current solution. since have complete tree maximum depth n, can like:

foreach lev1 [.tree children {}] {     do_stuff $lev1      foreach lev2 [.tree children $lev1] {         do_stuff$lev2         foreach lev3 [.tree children $lev2] {             do_stuff $lev3                ....         }     } } 

but looking easier way it.

i have considered adding tag (say mytag) each node , use: .tree tag has mytag list of nodes. problem that, afaik, resulting order not guaranteed , may end different type of visit.

recursive traversal ought trick you. along lines of

proc traverse {item} {     do_stuff $item     foreach [.tree children $item] {         traverse $item     } }   .tree traverse {} 

feels simple too.

(disclaimer: haven't tested this.)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -