Getting started with Python for Windows GUI programs

Source: Internet
Author: User
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:)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.