Getting started with using Python to develop Windows GUI programs _python

Source: Internet
Author: User

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:

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.