I am coming back to ask my own question. I don't think this is the perfect solution, but it managed my way out.
Here is the code:
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, 0, 'wxPython pull-down choice', size = (400, 300))
panel_select_model= wx.Panel(self, -1)
model_list = ['Test_A', 'Test_B']
self._model_type = None
self._stat_tex = wx.StaticText(panel_select_model, 1, "Select Model Type:", (15, 20))
self._droplist = wx.Choice(panel_select_model, 2, (150, 18), choices = model_list)
""" Bind A Panel """
self._droplist.SetSelection(0)
self._droplist.Bind(wx.EVT_CHOICE, self.choice_click)
""" Bind B Panel """
self._droplist.SetSelection(1)
self._droplist.Bind(wx.EVT_CHOICE, self.choice_click)
def choice_click(self, event):
if self._droplist.GetStringSelection() == "Test_A":
self.Test_A__click()
elif self._droplist.GetStringSelection() == "Test_B":
self.Test_B_click()
In above code. I put another layer between the wx.Choice component and the functions that I would like to trigger. Once we have a match, its corresponding function will be triggered.
I am afraid this is not an effective way. So I would be extremely appreciate if anyone can bring up a good solution. Thanks a lot.