By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,767 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

Tix Tree open/close issue

P: n/a
Hi,

I tried for the first time a Tix Tree, so, if my
question is naive, I apologize upfront.

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')
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).

How should I proceed?

Thanks,
Sorin

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Jul 13 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sorin Schwimmer wrote in news:mailman.8142.1152816058.27775.python-
li**@python.org 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...ree-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/
Jul 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.