Select to view content in your preferred language

wxpython

2956
5
11-20-2010 12:35 PM
MikeHunter
Occasional Contributor
For those of you who have wxpython installed, try this:  In the Arcmap python window, type "import wx" and press Enter.  What do you get?  What I get is a complete crash of the entire Arcmap application.  I guess we're stuck with Tkinter until esri gets this fixed.  Comments?

thanks
Mike
0 Kudos
5 Replies
JasonScheirer
Regular Contributor II
Which version of wx and Python are you using?

QT with PyQT may be a more viable option, I know that behaves a lot better when embedded in apps with their own event loops.
0 Kudos
MikeHunter
Occasional Contributor
Jason, I'm using the Python2.6 that installed with Arcgis 10 and wxPython 2.8.11.0 Unicode.  But this is not new--I got the same result with Arcgis 9.3 (Python 2.5) if I tried to import wx in a toobox script.

thanks
Mike
0 Kudos
NadeemQazi
New Contributor III
i used the import wx in ARCMap10.1 and it is crashed. any remedy to do it as i want to use the multimedia of wx in my application.
0 Kudos
TonyHowze
Occasional Contributor
Has anyone found a solution to this?
0 Kudos
RyanForbes1
New Contributor III
Tony,

Not sure if you're still looking for a solution since it's been a while since this thread has been touched but it came up in my searches and I would like to offer a solution so that folks in the future can see it too.

I was able to get around this issue by writing a separate script, saving it as a .pyw (thus forcing pythonw.exe to read it, rather than python.exe) and then importing it as a 'library' into my main script.  Since I am at the moment writing a Python Add-in for Arc Catalog I'll use that as an example.

First you write the code that gives you your window/app/etc

#!/usr/bin/python
#wxWorkAround.pyw

import wx

# This just gives up a blank, re-sizable window.
def main():
 app = wx.App()

 frame = wx.Frame(None, -1, 'simple.py')
 frame.Show()

 app.MainLoop()


(Lets say you were trying to have a window pop up when you clicked a button in a Python Add In) Save that script as a .pyw and then import it like you would any other script, and then call it like this:

class sampleButton(object):
    """Implementation for GRRTool_addin.sampleButton (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False

    def onClick(self):
        wxWorkAround.main()



It has worked for me (at least within ArcCatalog), so I hope this helps somebody in the future.
0 Kudos