wxPython combobox execution at 'apply'

One hassle, I am unable to close main frame. This script is part of ArcGIS 10.1 which isn’t responding to “self.Show(False)”. This combobox is called from a tool (combobox is visible once tool finished its job) and after pressing “Apply” button, this frame is still visible which means that it initiated another similar event. Can anyone please suggest how to close frame once i click ‘Apply’ button. Apparently “self.Destroy()” isn’t working as well.

···

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

Hi Ibraheem,

···

On 26/04/2013 18:01, Ibraheem Khan wrote:

One hassle, I am unable to close main frame. This script is part of ArcGIS 10.1 which isn't responding to "self.Show(False)". This combobox is called from a tool (combobox is visible once tool finished its job) and after pressing "Apply" button, this frame is still visible which means that it initiated another similar event. Can anyone please suggest how to close frame once i click 'Apply' button. Apparently "self.Destroy()" isn't working as well.

I haven't followed the thread from the beginning but to me the last few posts sound like it would help if you create a self contained little application showing your problem.

http://wiki.wxpython.org/MakingSampleApps

Werner

The problem is that he’s trying to use wx within ArcGIS and I don’t think ArcGIS fully supports wx. I’m pretty sure I linked him to a couple of threads on the topic already in another thread, but I can’t find that now. Anyway, unless someone else on the mailing list has ArcGIS, I don’t know how much troubleshooting we will be able to do.

I suppose the OP could try to use something like this:

import sys
sys.exit(0)

Although I don’t know if that will work very well in wxPython.

  • Mike
···

On Friday, April 26, 2013 11:33:30 AM UTC-5, werner wrote:

Hi Ibraheem,

On 26/04/2013 18:01, Ibraheem Khan wrote:

One hassle, I am unable to close main frame. This script is part of
ArcGIS 10.1 which isn’t responding to “self.Show(False)”. This
combobox is called from a tool (combobox is visible once tool finished
its job) and after pressing “Apply” button, this frame is still
visible which means that it initiated another similar event. Can
anyone please suggest how to close frame once i click ‘Apply’ button.
Apparently “self.Destroy()” isn’t working as well.

I haven’t followed the thread from the beginning but to me the last few
posts sound like it would help if you create a self contained little
application showing your problem.

http://wiki.wxpython.org/MakingSampleApps

Werner