Today can finally use Wxpython to develop GUI program, very happy. Write down some of the points of attention for reference. Under the Windows XP platform, you first need to configure the following environments:
1. First, install Python and add the Python/bin directory to path after installation.
2. Install Wxpython, and be aware that the Wxpython version is consistent with the previous Python version.
3. Install Py2exe, which is a very good Python program publishing tool under the Windows platform, can compile the Python program into EXE and run out of the Python environment. After we finish the installation, we can test it.
WxPython Demo Code:
The code is as follows:
#wxDemo. py
Import WX
The Class App (WX. APP):
def OnInit (self):
frame = wx. Frame (Parent=none, title= ' Bare ')
Frame. Show ()
Return True
App = App ()
App. Mainloop ()
Compile code to write Py2exe:
The code is as follows:
#setup. py
From Distutils.core Import Setup
Import Py2exe
Setup (windows=["wxdemo.py"])
Note that the setup (windows=["wxdemo.py") in the above code correctly references your Python program, [] in the Python program file you want to compile, because it is windowed, Windows properties are used.
below 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 compiled EXE, at the time of release, you need to put the folder below the Library.zip,dll and WxDemo.exe in the same directory, or the program can not be executed. Now, double-click on the WxDemo.exe and you'll see a window:)