GTK2.TreeView

View: New views
3 Messages — Rating Filter:   Alert me  

GTK2.TreeView

by larcky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all

Has anyone had any success with GTK2.TreeView in Pike (7.8.316)?
I've got as far as setting the TreeView's model (thanks to James Trike's fix) - a ListStore with one string - but can't work out how to use TreeView->append_column().
The module docs seem to suggest you need to set up your own CellRenderer, whereas in gtkmm you can just use a default renderer for basic types.

Here's a snippet:

my_user_list = GTK2.ListStore( ({"string"}) );
my_tree_view->set_model(my_user_list);
 
// next 2 lines garbage - but they do give you column header
GTK2.CellRendererText crt = GTK2.CellRendererText();
my_tree_view->append_column( GTK2.TreeViewColumn("Usernames", crt, "", 0) );

// this never gets drawn
GTK2.TreeIter iter = my_user_list->append();
my_user_list->set_value(iter, 0, "someuser");

Thanks in advance for any help,
Matthew

Re: GTK2.TreeView

by Lance Dillon-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The attached test should work, and if so, that would be how you would do it.



----- Original Message ----
From: larcky <pclar7@...>
To: pike@...
Sent: Saturday, September 19, 2009 5:29:20 AM
Subject: GTK2.TreeView


Hi all

Has anyone had any success with GTK2.TreeView in Pike (7.8.316)?
I've got as far as setting the TreeView's model (thanks to
http://www.nabble.com/Getting-GObjects-from-mixin-objects-td3589654.html
James Trike's fix ) - a ListStore with one string - but can't work out how
to use TreeView->append_column().
The module docs seem to suggest you need to set up your own CellRenderer,
whereas in gtkmm you can just use a default renderer for basic types.

Here's a snippet:

my_user_list = GTK2.ListStore( ({"string"}) );
my_tree_view->set_model(my_user_list);

// next 2 lines garbage - but they do give you column header
GTK2.CellRendererText crt = GTK2.CellRendererText();
my_tree_view->append_column( GTK2.TreeViewColumn("Usernames", crt, "", 0) );

// this never gets drawn
GTK2.TreeIter iter = my_user_list->append();
my_user_list->set_value(iter, 0, "someuser");

Thanks in advance for any help,
Matthew

--
View this message in context: http://www.nabble.com/GTK2.TreeView-tp25519989p25519989.html
Sent from the Pike - User mailing list archive at Nabble.com.


     

treestore.pike (2K) Download Attachment

Re: GTK2.TreeView

by larcky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just rewrote things using your example as a guide and it now works perfectly.  Thanks :)
For the record, these are my changes:

my_user_list = GTK2.ListStore( ({"string"}) );
my_tree_view->set_model(my_user_list);
my_renderer = GTK2.CellRendererText(); // type = GTK2.CellRenderer
username_col = GTK2.TreeViewColumn("Username", my_renderer, "text", 0);
my_tree_view->append_column(username_col);

GTK2.TreeIter iter = my_user_list->append();
my_user_list->set_row( iter, ({"someuser"}) );

Lance Dillon-2 wrote:
The attached test should work, and if so, that would be how you would do it.