How to add list items with combobox or comboboxentry

Asked by selvamani on 2010-03-27

i am playing with quickly and glade. could you tell me how to add list items into comboboxentry or combobox. If you give the code snippets, it would be grateful.

Thank You,

With regards,

Selvamani.

Question information

Language:
English Edit question
Status:
Solved
For:
Quickly Edit question
Assignee:
No assignee Edit question
Solved by:
Rick Spencer
Solved:
2010-03-31
Last query:
2010-03-31
Last reply:
2010-03-28

You can do this with Glade. Once you do it, it makes sense, but it is not terribly discoverable unless you have a good detailed knowledge of using Gtk.

For a comboboxentry:
1. Select the comboboxentry
2. Go to the General tab in the properties pan
3. Under ComboBox model, click the builder button "..."
You will see the "Choose a GTKTreeModel in the project" dialog. In this dialog:
4. Click New
A liststore will be added to you project. It will be in the tree view in the inspector under "objects" and called liststore1.
5. Select listore1
6. Select the general tab
7. Under Add and Remove Columns, make a Column of type gchararry, with whatever name you like, "Title" for instance.
8. Under "Add and remove rows" click the + sign
9. In the created row, type in the string that you want.
10. Repeat 8 and 9 until you have all the strings that you want
11. Select your combo again
12. Change the Text Column property 0 (zero)

Run your app, and you see the list you added.

Cheers, Rick

And if you just want to do it in code, you can see here:
http://faq.pygtk.org/index.py?req=show&file=faq14.013.htp

The pygtk faq is very useful and full of good snippets.

selvamani (selvamani) said : #3

I am grateful to you Mr. Rick Spencer. It is working properly when i tried to do the things whatever input you gave. In my project, i require the back end database couchDB to store all the data which i am getting from the widgets. Can you tell me how to store the data given in the widget. I would be thankful if you would give the required snippets for linking the widget to CouchDB.

With Regards,

Selvamani. S

--- On Sun, 28/3/10, Rick Spencer <email address hidden> wrote:

> From: Rick Spencer <email address hidden>
> Subject: Re: [Question #105667]: How to add list items with combobox or comboboxentry
> To: <email address hidden>
> Date: Sunday, 28 March, 2010, 9:26 AM
> Your question #105667 on quickly
> changed:
> https://answers.edge.launchpad.net/quickly/+question/105667
>
>     Status: Open => Answered
>
> Rick Spencer proposed the following answer:
> You can do this with Glade. Once you do it, it makes sense,
> but it is
> not terribly discoverable unless you have a good detailed
> knowledge of
> using Gtk.
>
> For a comboboxentry:
> 1. Select the comboboxentry
> 2. Go to the General tab in the properties pan
> 3. Under ComboBox model, click the builder button "..."
> You will see the "Choose a GTKTreeModel in the project"
> dialog. In this dialog:
> 4. Click New
> A liststore will be added to you project. It will be in the
> tree view in the inspector under "objects" and called
> liststore1.
> 5. Select listore1
> 6. Select the general tab
> 7. Under Add and Remove Columns, make a Column of type
> gchararry, with whatever name you like, "Title" for
> instance.
> 8. Under "Add and remove rows" click the + sign
> 9. In the created row, type in the string that you want.
> 10. Repeat 8 and 9 until you have all the strings that you
> want
> 11. Select your combo again
> 12. Change the Text Column property 0 (zero)
>
> Run your app, and you see the list you added.
>
> Cheers, Rick
>
> --
> If this answers your question, please go to the following
> page to let us
> know that it is solved:
> https://answers.edge.launchpad.net/quickly/+question/105667/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go
> to the
> following page to enter your feedback:
> https://answers.edge.launchpad.net/quickly/+question/105667
>
> You received this question notification because you are a
> direct
> subscriber of the question.
>

      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/

selvamani (selvamani) said : #4

I am grateful to you Mr. Rick Spencer. It is working properly when i
tried to do the things whatever input you gave. In my project, i require
the back end database couchDB to store all the data which i am getting
from the widgets. Can you tell me how to store the data given in the
widget. I would be thankful if you would give the required snippets for
linking the widget to CouchDB.

Thinking,

Selvamani

E. E. Perry (elmerp) said : #5

If I do the above with a combo box, I get a error when I try to save it in glade. Changing the text column property seems to be the problem. If I set it to anything other than -1, it gives an error when trying to save. Any ideas?