gnope php gtk gui gnope.org  

Comboentry in liststore

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
meman



Joined: 25 Feb 2006
Posts: 11
Location: Germany

PostPosted: Tue Mar 21, 2006 9:19 pm    Post subject: Comboentry in liststore Reply with quote

Hi there,

is there any possibility to crate a column within a liststore, where i get a dropdown list when i edit this cell?? maybe its possible with cellrenderercombo, but i have no idea how to start.
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Tue Mar 21, 2006 9:55 pm    Post subject: Reply with quote

When creating the column, you need to pass the cellrenderercombo instance as renderer.
Back to top
meman



Joined: 25 Feb 2006
Posts: 11
Location: Germany

PostPosted: Thu Mar 23, 2006 5:34 pm    Post subject: Reply with quote

yeah, but how do i implement the items for the dropdownlist, the same way as with the comboboxentry??
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Thu Mar 23, 2006 5:40 pm    Post subject: Reply with quote

You have to set the model, and the text-column property.

Code:

//List with allowed categories
$categories = new GtkListStore(Gtk::TYPE_STRING);
$categories->append(array('Editors'));
$categories->append(array('Games'));
$categories->append(array('Setup'));
$categories->append(array('Office'));

//Column: Category
$rendererCategory = new GtkCellRendererCombo();
$rendererCategory->set_property('model'      , $categories);
$rendererCategory->set_property('text-column', 0);
$rendererCategory->set_property('editable'   , true);
//$rendererCategory->set_property('has-entry'  , false);

$columnCategory = new GtkTreeViewColumn(
    'Category',        //title
    $rendererCategory, //the renderer
    'text',            //use that property
    2                  //data is in that model column
);
$view->append_column($columnCategory);

Back to top
meman



Joined: 25 Feb 2006
Posts: 11
Location: Germany

PostPosted: Sun Mar 26, 2006 10:38 am    Post subject: Reply with quote

Looks great, i will try it today.
thanx a lot christian.
but one more question: is it possible to have a tree inside the dropdownlist instead of a simple list?? and how is it done?
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Sun Mar 26, 2006 9:58 pm    Post subject: Reply with quote

meman wrote:
is it possible to have a tree inside the dropdownlist instead of a simple list?

It should be possible, if you use a GtkTreeStore instead of a GtkListStore
Back to top
meman



Joined: 25 Feb 2006
Posts: 11
Location: Germany

PostPosted: Mon Mar 27, 2006 11:52 am    Post subject: Reply with quote

yep, i found out how its done on my own yesterday.
thx a lot for your help
Back to top
ssiwek



Joined: 15 May 2006
Posts: 20

PostPosted: Thu Sep 21, 2006 4:27 pm    Post subject: Reply with quote

Hi!

How do I preset a value for a categorie in the GtkCellrendererCombo?

And how do I retrieve a value from that?

have a nice day
Sven
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.