wxPython combobox execution at 'apply'

Iam using “EVT_TEXT_ENTER” to wait for the selection but nothing happens upon pressing ‘Apply’ button. Please suggest what event type should i use to bind all selections together instead of one by one?

···

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_…

In your button event handler, you’ll have to grab the values from the comboboxes and then process them accordingly.

  • Mike
···

On Thursday, April 25, 2013 10:46:49 AM UTC-5, Ibraheem Khan wrote:

Iam using “EVT_TEXT_ENTER” to wait for the selection but nothing happens upon pressing ‘Apply’ button. Please suggest what event type should i use to bind all selections together instead of one by one?

Ibraheem Khan wrote:

Iam using "EVT_TEXT_ENTER" to wait for the selection but nothing
happens upon pressing 'Apply' button. Please suggest what event type
should i use to bind all selections together instead of one by one?

You need to describe to yourself how you would like the window to work.
Describe it in words, and then make the code meet those words. Don't
add event handlers at random. If you only want to take action when the
user presses the "apply" button, then why would you bind to any other
events? Do all of your handling in the OnClose handler. You already
know how to pull values from the controls (self.Soil.GetValue()).

···

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