On Mon, Dec 06, 1999 at 05:06:08AM +1000, Rob Hodges wrote:
> 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.)

Use GtkCList's columns_autosize method.

> 
> 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?)

Instead of text, give him list of texts.

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


--- ab.py.orig  Mon Dec  6 09:27:52 1999
+++ ab.py       Mon Dec  6 09:28:13 1999
@@ -5,14 +5,12 @@
 
 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' (???)
+basenode = tree.insert_node(None,None,['base'],expanded=TRUE,is_leaf=FALSE)
 for name in map(str, range(100)):
-    n = tree.insert_node(basenode, None, " ")
-    tree.node_set_text(n, 0, name)
+    n = tree.insert_node(basenode, None, [name])
 for node in tree.base_nodes():
     tree.sort_recursive(node)
-
+tree.columns_autosize()
 treewin = GtkScrolledWindow()
 treewin.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
 win.add(treewin)
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to