I was wondering if anybody could explain how a GtkCTree goes about
deciding how wide it is?  (Or more to the point, how to make one only
be as wide as it needs to be, to contain its contents -- I'd like to
be able to place one inside a scrolled window and have the horizontal
scrollbar represent the width of the contents -- which of course is
what normally happens automatically with most widgets.)

Furthermore, something strange happens if you put one inside a
GtkScrolledWindow with POLICY_AUTOMATIC set on the scrollbars: each
time you expand and collapse the tree, it gets wider!  Can anybody
shed light on this oddity?

(Also, is it a bug that the text argument to GtkCTree.insert_node is
seemingly truncated after the first character?)

The following script is sufficient to demonstrate the width-altering
behaviour:

----------------------------------------
#! /usr/bin/env python
from gtk import *

win = GtkWindow()

tree = GtkCTree()
tree.show()
basenode = tree.insert_node(None,None,'base',expanded=TRUE,is_leaf=FALSE)
tree.node_set_text(basenode,0,'base') #otherwise we only get 'b' (???)
for name in map(str, range(100)):
    n = tree.insert_node(basenode, None, " ")
    tree.node_set_text(n, 0, name)
for node in tree.base_nodes():
    tree.sort_recursive(node)

treewin = GtkScrolledWindow()
treewin.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
win.add(treewin)
treewin.add(tree)
treewin.show()

win.connect("delete_event", mainquit)
win.show()
mainloop()
----------------------------------------

Thanks,

-Rob

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to