Sorin Schwimmer wrote in news:mailman.8142.1152816058.27775.python-
[EMAIL PROTECTED] in comp.lang.python:

> The following code:
> <code>
> from Tix import *
> 
> r=Tk()
> 
> tr=Tree(r)
> tr.subwidget('hlist').add('br1',text='branch 1')
> tr.subwidget('hlist').add('br1.b1',text='branch 1-1')
> tr.subwidget('hlist').add('br1.b1.b1',text='branch
> 1-1-1')
> tr.subwidget('hlist').add('br1.b1.b2',text='branch
> 1-1-2')
> tr.subwidget('hlist').add('br1.b2',text='branch 1-2')
> tr.subwidget('hlist').add('br1.b2.b1',text='branch
> 1-2-1')
> tr.subwidget('hlist').add('br1.b2.b2',text='branch
> 1-2-2')
> r.tk.call(tr,'setmode','br1','close')
> r.tk.call(tr,'setmode','br1.b1','open')
> r.tk.call(tr,'setmode','br1.b2','open')
> #tr.setmode('br1','close')
> #tr.setmode('br1.b1','open')
> #tr.setmode('br1.b2','open')

Try instead:

tr.setmode('br1.b1','close')
tr.setmode('br1.b2','close')
tr.setmode('br1','close')
tr.close('br1.b2')
tr.close('br1.b1')

> tr.grid()
> 
> r.mainloop()
> </code>
> 
> will show the whole tree, but will set correctly the
> (+) and (-) boxes. (The commented out statements where
> in place before direct calls to Tk - same result).
> 
> I was hoping to have some branches hidden (the leaves,
> in this case).

My solution above make any sense till I read the docs, 

http://epydoc.sourceforge.net/stdlib/public/Tix.Tree-class.html

<quote>
say:

setmode(self, entrypath, mode='none') 

[snip]
...                       If mode is set to close, a (-)
indicator is drawn next the the entry. 
...                       The
open mode indicates the entry has hidden children and this entry can be
opened by the user. The close mode indicates that all the children of the
entry are now visible and the entry can be closed by the user.
</quote>

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to