Today, I can finally use Wxpython to develop GUI program, very happy. Write down some of these notes for your reference. Under the Windows XP platform, you first need to configure the following environments:
1. The first is to install Python, after installation, add the Python/bin directory to the path.
2. Install Wxpython, at this point to note that the version of Wxpython to be consistent with the previous version of Python.
3. Install Py2exe, this is the Windows platform under a very good Python program publishing tool, you can compile Python program into EXE and out of the Python environment execution. Once we've done the installation, we can test it.
WxPython Demo Code:
Copy Code code as follows:
#wxDemo. py
Import WX
Class App (WX. APP):
def OnInit (self):
frame = wx. Frame (Parent=none, title= ' Bare ')
Frame. Show ()
Return True
App = App ()
App. Mainloop ()
To write the compiled code for Py2exe:
Copy Code code as follows:
#setup. py
From Distutils.core Import Setup
Import Py2exe
Setup (windows=["wxdemo.py"])
Note that Setup (windows=["wxdemo.py"]) in the code above is going to refer to your Python program correctly, and the Python program file you want to compile is used with Windows properties because it's a window.
Here's how to compile:
Execute Python setup.py py2exe at the command line, and when the compilation is complete, there will be a dist folder, There is a wxDemo.exe, this is the compiled EXE, in the release, you need to put the folder below the Library.zip,dll and WxDemo.exe under the same directory, otherwise the program can not be executed. Now, double click on the WxDemo.exe and you'll see a window: