note 157 added to gtk.gtkctree.php
| From: | monkey@php.net | Date: | Fri, 28 Jun 2002 17:45:08 +0000 |
| Subject: | note 157 added to gtk.gtkctree.php | ||
| Groups: | php.gtk.webmaster | ||
| Request: | Send a blank email to php-gtk-webmaster+get-506@lists.php.net to get a copy of this message | ||
I'm just starting to figure this one out; most of the examples use all sorts of clever arrays
and recursion to construct the tree, which makes it awfully hard to understand the basic mechanics
of putting the thing together.
I found a very helpful example in the form of a Python class in a pygtk mailing list at:
http://www.daa.com.au/pipermail/pygtk/2001-July/001488.html
I ported it to PHP as straight procedural code (no classes or functions) so I could see a plain
vanilla, simple CTree object at work - this is what I came up with:
----------------------------------------
<?php
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
else
dl('php_gtk.so');
$win = &new GtkWindow();
$win->connect('destroy', 'destroy');
function destroy(){
Gtk::main_quit();
}
$tree = &new GtkCTree(1,0);
$node = $tree->insert_node(null,null,array("Hello"), 0, null,null,null,null, false,
true);
$leaf = $tree->insert_node($node,null,array("World"), 0, null,null,null,null, true,
false);
$win->add($tree);
$win->show_all();
GTK::main();
?>
--------------------------------------
Hope this helps - I can see that doing anything useful with CTrees is going to be a royal pain. ;)
-Andy
http://gtk.php.net/manual/en/gtk.gtkctree.php