[pygtk] combobox selection
Lupine
thelupine.mailinglists at gmail.com
Wed May 27 20:18:13 WST 2009
On Tue, 2009-05-26 at 13:12 +0530, anusha k wrote:
> i have a combobox when i press specific letter that list starting with
> that letter should come up.so what should i do for that
> what it is named in pygtk.for example:i have cities in a combobox when
> i press M lette,r cities staring with M should show up.
> i know about gtk.comboboxentry and gtk.entrycompletion,but is it
> possible with combobox.
>
Yes, this is possible with a GtkComboBoxEntry. Here is an example I
use, using Glade and GtkBuilder:
Glade code:
<object class="GtkComboBoxEntry" id="host_entry_cmbox">
<property name="visible">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="host_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="activate" handler="on_host_entry_activate"/>
<signal name="changed" handler="on_host_entry_changed"/>
</object>
</child>
</object>
Python code:
def populate_cmbox_hostlist_entry_completion(self):
hostnames = read_hostsfile()
if hostnames:
completion = gtk.EntryCompletion()
hosts = gtk.ListStore(str)
for hostname in hostnames:
iter = hosts.append()
hosts.set(iter, 0, hostname)
self.host_entry.set_completion(completion)
completion.set_model(hosts)
completion.set_text_column(0)
Hope that helps,
-Lup
More information about the pygtk
mailing list