We do hope to support wxPython in the future as the Python UI Framework for hooking into ArcGIS Desktop.
Thanks,
Jason Pardy
Esri
import arcpy import pythonaddins import wx class TestButtonClass(object): """Implementation for wxTest_addin.TestButton (Button)""" dlg = None def __init__(self): self.enabled = True self.checked = False def onClick(self): if self.dlg is None: self.dlg = TestDialog() else: self.dlg.Show(True) return class TestDialog(wx.Frame): def __init__(self): wxStyle = wx.CAPTION | wx.RESIZE_BORDER | wx.MINIMIZE_BOX |wx.CLOSE_BOX | wx.SYSTEM_MENU wx.Frame.__init__(self, None, -1, "Set DataFrame Name", style=wxStyle, size=(300, 120)) self.SetMaxSize((300, 120)) self.SetMinSize((300, 120)) self.Bind(wx.EVT_CLOSE, self.OnClose) panel = wx.Panel(self, -1) self.lblStatus = wx.StaticText(panel, -1, "OK", pos=(8, 8)) wx.StaticText(panel, -1, "Title:", pos=(8,36)) self.tbTitle = wx.TextCtrl(panel, -1, value="", pos=(36, 36), size=(200,21)) self.btnSet = wx.Button(panel, label="Set", pos=(8, 66)) self.Bind(wx.EVT_BUTTON, self.OnSet, id=self.btnSet.GetId()) self.Show(True) def OnClose(self, event): self.Show(False) # self.Destroy() doesn't work def OnSet(self, event): # Use str() to strip away Unicode crap sTitle = str(self.tbTitle.GetValue()) mxd = arcpy.mapping.MapDocument("CURRENT") df = mxd.activeDataFrame df.name = sTitle arcpy.RefreshTOC() app = wx.PySimpleApp() app.MainLoop()
We do hope to support wxPython in the future as the Python UI Framework for hooking into ArcGIS Desktop.
Thanks,
Jason Pardy
Esri
Alright!!!
I have written a Python script using wxPython that runs inside ArcMap. It runs fine from the Python Command Line inside ArcMap, but if it is launched from an ArcMap Add-In, it runs once without a problem, but if it is run a second time in the same ArcMap session, it crashes ArcMap. If it is launched from a Toolbar Tool, it crashes ArcMap immediately. More details here:
https://community.esri.com/message/769441-is-wxpython-incompatible-with-arcmap-add-ins-and-tools