This article mainly introduces how to use Python to develop a Windows GUI program entry instance. This article focuses on the software necessary for the development environment, and the code implementation is relatively simple, for more information, see wxPython. Write down some notes for your reference. On windows XP, configure the following environment:
1. install python first. after installation, add the directory of python/bin to path.
2. install wxPython. Note that the wxPython version must be consistent with the previous python version.
3. install py2exe. this is a very good python program release tool on the windows platform. it can compile the python program into an exe and run it out of the python environment. After the above installation, we can test it.
WxPython demo code:
The code is 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 ()
Compile the compilation code for py2exe:
The code is as follows:
# Setup. py
From distutils. core import setup
Import py2exe
Setup (windows = ["wxDemo. py"])
Note that setup (windows = ["wxDemo. py "]) to correctly reference your Python program, the python program file to be compiled in [] uses the windows attribute because it contains a window.
Compile as follows:
Run python setup. py py2exe on the command line and put the handler in the same directory. Otherwise, the program cannot be executed. Now, double-click wxdemo.exe and you will see a window :)