Hi,
the code above seems ok (for what it is supposed to do:).
What specific error (including the whole traceback) do you get? What
OS, python and wxpython version are you using?
If you are using python Idle to run the code, you may get some errors
in some more complex programs eventually, as there are two GUI systems
interfering (Tk and wx), however, this code works for me inside Idle
too.
hth,
vbr
···
2012/7/21 Daniel Montenegro <dmontenegro84@gmail.com>:
Hi there!
Could someone say why this code isn't working? I mean, I run it (F5) at
Python Shell but then I receive a error message.
Well, I'm using Python 2.7... as far as I know I've installed the right
wxpython version (2.7). The OS is Windows 7.
Which version of wxPython? There will be two numbers in the installer file's name, one is the wxPython version, and the other is the version of Python that it was built for.
This is the message error:
app = wx.App()
AttributeError: 'module' object has no attribute 'App'
I really don't know why this is happening.
Either your wxPython install is broken, or was installed for the wrong Python, or there is some other wx package or module being found first. Look at the values in sys.path, and then examine each of the folders in that list. Check for any wx folder with a __init__.py in it, or a wx.py file. If there are either of those in a folder that comes before the real wxPython in your sys.path then that is the problem. Remove it.
Next check the wxPython install path. It should be something like {PythonLibDir}/site-pacakges/wx-X.Y-msw-unicode, and inside that folder will be the wx package. In {PythonLibDir}/site-pacakges there will also be a wx.pth file that contains the name of the wx-X.Y-msw-unicode folder, which is how it gets added to the sys.path.