wxPython combobox execution at 'apply'

I am relatively new to wxPython so would really appreciate if you can help me with a simple example of how to grab combobox values using button event handler.

Thx!

···

On Thursday, April 25, 2013 9:52:36 AM UTC-4, Ibraheem Khan wrote:

Hi,

I am using two combobox on a single frame and running into a problem. Whenever i select an option from combobox1 then the associated processes are executed instead of waiting for me to finish selecting option from combobox2 and press ‘apply’ button. Please suggest where things are going out of control. Thanks!
Following is code snippet:

class ComboBoxFrame(wx.Frame):

def init(self):

wx.Frame.init(self, None, -1, ‘Input Data Selection’, size=(350, 300))

self.Bind(wx.EVT_CLOSE, self.OnClose)

panel = wx.Panel(self, -1)

wx.StaticText(panel, -1, “Select Soil Data”, (15, 15))

SoilList = [soil1’, ‘soil2’, ‘soil3’]

self.Soil = wx.ComboBox(panel, -1, “”, (15, 30), wx.DefaultSize,SoilList, wx.CB_DROPDOWN)

self.Soil.Bind(wx.EVT_COMBOBOX, self.OnSelect, self.Soil)

wx.StaticText(panel, -1, “Select Hyd Condition”, (15, 15))

HydList = [‘h1’, ‘h2’, ‘h3’]

self.Hyd = wx.ComboBox(panel, -1, “”, (15, 30), wx.DefaultSize,HydList, wx.CB_DROPDOWN)

self.Hyd.Bind(wx.EVT_COMBOBOX, self.OnSelect, self.Hyd)

self.btnApply = wx.Button(panel, label=“Apply”, pos=(65, 200))

self.Bind(wx.EVT_BUTTON, self.OnClose, id=self.btnApply.GetId())

self.Show(True)

def OnClose(self, event):

self.Show(False)

def OnSelect(self, event):

soil = str(self.Soil.GetValue())

do_something_…

Try calling the combo box’s GetValue() method. Something like

soil_value = self.Soil.GetValue()

···

On Thursday, April 25, 2013 11:04:32 AM UTC-5, Ibraheem Khan wrote:

I am relatively new to wxPython so would really appreciate if you can help me with a simple example of how to grab combobox values using button event handler.
Thx!