简体   繁体   中英

wxPython: refresh and update combobox

I got a wxPython combobox which contains a list of sections of my.ini file. I add new section while my program is running. And I also want to see the NEW entries in my combobox.

How can I refresh / update it?

My code:

self.cbxCfgProfiles = wx.ComboBox(self, pos=(170, 120), size=(440, -1),   
                                  choices=getCfgProfileList(), style=wx.CB_DROPDOWN)

When I restart my program I see the new entries.

I try already self.cbxCfgProfiles.Refresh() in my method. It does not work. :(

If you have a new list of strings that you want to set the combobox to, the SetItems() method is probably the easiest way. It clears the control and then adds all the new selections.

Sorry I only worked with pyGtk until now, and one alternative for you it's to make a thread that verifies wheter there is a new section at your.ini file that isn't on a dict with the same values already loaded to your combobox and the items that wheren't on that dict you can insert them. I think this will help:

wx.ComboBox.Insert()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM