[pygtk] Add a combo button
Daniel Woodhouse
wodemoneke at gmail.com
Wed Jul 8 15:58:23 WST 2009
the simple way:
#create a new empty combobox
combo_box = gtk.combo_box_new_text()
items = ["Item 1", "Item 2" ......]
for item in items:
combo_box.append_text(item)
#we need to know the name of the container we are putting the combobox in
#In this case I have set the name of the gtk.HBox in glade to
"combo_container"
self.wTree.get_widget("combo_container").pack_start(combo_box)
#set the 1st item as selected
combo_box.set_active(0)
combo_box.show()
These are the methods you can use to add and remove text:
append_text(text)
prepend_text(text)
insert_text(index, text)
remove_text(index, text)
To see what is currently selected we can use:
group_box.get_active_text()
There is another way of creating combo boxes, but its a bit more involved, I
think this is suitable for most situations.
Regards,
Daniel Woodhouse
On Wed, Jul 8, 2009 at 8:58 AM, surabhi dwivedi <
surabhi.dwivedi at rediffmail.com> wrote:
> Hello
>
> I am very new to glade/GTK/Python. I have designed a page using GLADE and
> that I am running using python , I want to add a combo box in that and
> execute that at run time .Can you help me how should I proceed.
>
> Thanks and Regards
>
> <http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline.htm@Middle?>
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090708/1b81e1e4/attachment.htm
More information about the pygtk
mailing list