wxPython : Change ComboBox choices

I’m trying to change the choices of the second ComboBox if the user chooses “Campaign” in the first ComboBox.

The code below is not working, I mean the choices on the second ComboBox remain the same.

I need your help with this one. Thank you,

    class Test(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id, "Frame aka Window", style= wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX, size=(400, 635))
self.filterValues = ['Campaign','Spent', 'Network Impr.', 'Network Clicks', 'Rev. /1000', 'GA Impr.', 'Revenue', 'eCPC', 'CPC', 'CTR'] self.filterComboColumns = wx.ComboBox(self.panel,choices = self.filterValues, size = (100,-1))
self.Bind(wx.EVT_COMBOBOX, self.onComboValues, self.filterComboColumns)
self.filterContainsValues = ['Contains', 'Don\'t contain' , '<', '>'] self.filterComboContains = wx.ComboBox(self.panel,choices = self.filterContainsValues, size = (100,-1))
self.filterComboContains.Enable(False)
self.Bind(wx.EVT_COMBOBOX, self.onComboContains, self.filterComboContains)
self.filterInput = wx.TextCtrl(self.panel, wx.ID_ANY, size=(145, 24))
self.filterInput.Enable(False)
self.filterInput.SetFont(font)
self.Bind(wx.EVT_TEXT, self.onComboInput, self.filterInput)
def onComboValues(self, event): cb = event.GetEventObject() if cb.GetValue() == "Campaign":
self.filterComboContains.Enable(True)
self.filterContainsValues = []
self.filterContainsValues.append('Contains')
self.filterContainsValues.append('Don\'t contain')

Of course, because you never changed the combo box. You just changed a class variable. You want:

self.filterComboContains.SetItems( self.filterContainsValues )

···

On May 30, 2019, at 10:51 PM, Barb-Cr33k younes.boutriq@gmail.com wrote:

I’m trying to change the choices of the second ComboBox if the user chooses “Campaign” in the first ComboBox.

The code below is not working, I mean the choices on the second ComboBox remain the same.


Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.