I'm trying to prepare a Python add-in using "Python Add-In Wizard". I want my add-in to perform some geoprocessing but first it should take data from a user and there's already a problem. I'm displaying a wxpython GUI and it loses focus and hides behind the arcmap window almost immediately after it's shown. I have no idea how to debug it and what could cause the problem. I decided to go this way after getting hands on this example.
My code is here:
from dialogs.import_dialog import ImportDialog class ImportButton(object): """Runs the import function.""" dlg = None def __init__(self): self.enabled = True self.checked = False def onClick(self): if self.dlg is None: self.dlg = ImportDialog() else: self.dlg.Show()
class ImportDialog(wx.Frame): def __init__(self): wxStyle = wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU wx.Frame.__init__(self, None, wx.ID_ANY, "some msg", style=wxStyle, size=(350, 200)) self.panel = wx.Panel(self, wx.ID_ANY) self.path_label = wx.StaticText(self.panel, wx.ID_ANY, u"some msg", pos=(8, 8)) self.input_path = wx.TextCtrl(self.panel, wx.ID_ANY, value="", pos=(8, 36), size=(330, 21)) self.path_label = wx.StaticText(self.panel, wx.ID_ANY, u"some msg", pos=(8, 65)) self.group_layers = wx.ComboBox(self.panel, wx.ID_ANY, pos=(8, 93), size=(330, 21)) self.ok_button = wx.Button(self.panel, label="OK", pos=(8, 130)) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Center() self.Show(True) def OnClose(self, event): self.Show(False)