473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to delete PyGTK ComboBox entries?

Hello list!

I need to repopulate PyGTK ComboBox on a regular basis. In order to do
so I have to remove all the entries and then add the new ones. I tried
to remove all entries like that:

def clear_comboboxes(boxreference):
try:
while True:
boxreference.remove_text(0)
except:
pass

And then repopulate by iterating through the list of desired entries and
calling ComboBox.append_text(text). It works, but is painfully
sloooooooow! Is there a faster way to completely change the entries in a
ComboBox, by using an all erase method or overwriting the container
object? I haven't found anything with google, as the searches are too
ambiguous to yield usable results.

Thanks,

Maël
Feb 26 '07 #1
2 6064
ma, 2007-02-26 kello 16:08 +0100, Maël Benjamin Mettler kirjoitti:
I need to repopulate PyGTK ComboBox on a regular basis. In order to do
so I have to remove all the entries and then add the new ones.
And then repopulate by iterating through the list of desired entries and
calling ComboBox.append_text(text). It works, but is painfully
sloooooooow!
model = combo_box.get_model()
combo_box.set_model(None)
model.clear()
for entry in desired_entries:
model.append([entry])
combo_box.set_model(model)

model.append is essentially the same as combo_box.append_text. Setting
the model to None before making changes to it speeds things at least in
the case of tree views. I'm not sure if it does much with combo boxes.
If you experince speed issues with combo boxes you're either doing
something very wrong or you have so many entries that you ought to be
using a tree view instead.

--
Osmo Salomaa

Feb 26 '07 #2
Hej!

model = combo_box.get_model()
combo_box.set_model(None)
model.clear()
for entry in desired_entries:
model.append([entry])
combo_box.set_model(model)

model.append is essentially the same as combo_box.append_text. Setting
the model to None before making changes to it speeds things at least in
the case of tree views. I'm not sure if it does much with combo boxes.
If you experince speed issues with combo boxes you're either doing
something very wrong or you have so many entries that you ought to be
using a tree view instead.
Works like a charm. Thanks a lot!

Feb 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: j_mckitrick | last post by:
Hi all. Here is a tiny container for one of each combo box, along with the glade file. Just 2 widgets, so hopefully not too large. How the heck do I get the selection from the ComboBox, as...
6
by: Bernd Smits | last post by:
Hi, I would like to delete a record (with commandbutton) of a table associated to a combobox, when I select a certain value in the combobox (the value I select is associated with the record that I...
4
by: John Suru | last post by:
I am loading up a combobox with data from an access database. The field I am loading is a date/time datatype. The data in the field is a short date(ex. 01/22/2004). When I load the combobox with the...
5
by: Peter Stojkovic | last post by:
VB 7.1 and windows.forms. I have a comboBox on a form. When the user goes with TAB-Key to the comboBox, the comboBox should dropDown the ListBox automatically and show ALL entries. The user...
1
by: tizmagik | last post by:
I have a combobox on a continuous form that has a recordsource that is set upon Form_Load event via VBA (based on initial form data and external form data entered). For data entry purposes the...
0
by: Fabian Braennstroem | last post by:
Hi, I am just testing pygtk/glade out and wonder, if I am able to change the keybindings. E.g. the treeview searches by default for the entries beginning with the typed keystroke; moving to the...
5
by: active | last post by:
I tried to use a datasource with a combobox and it didn't work completely so I build a small test that was much more straight forward then the app. The test was to see if the combobox dropdown...
9
by: Greg (codepug | last post by:
I have a combobox with the RowSourceType set to Table/Query and the RowSource is an SQL query that references a separate lookup table that contains the data that can be selected in the combobox....
0
by: dudeja.rajat | last post by:
On Sat, Aug 30, 2008 at 2:32 PM, Fredrik Lundh <fredrik@pythonware.comwrote: Fredrik, Thanks so much. That worked. Following this, I can now see that my combo2 has no previous elements and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.