Example and introduction of Python-based Windows program code

Source: Internet
Author: User

The following articles describe the application code for developing windows programs using python, the related steps in practical applications, and the actual application solution for installing py2exe, the following is a detailed description of the article. I hope you will get some benefits.

Install py2exe. This is the next very good python program release tool on the windows platform. You can compile the python program into an exe and run it out of the python environment.

WxPython demo code:

Python code

 
 
  1. #wxDemo.py   
  2. import wx   
  3. class App(wx.App):   
  4. def OnInit(self):   
  5. frame = wx.Frame(parent=None, title='Bare')   
  6. frame.Show()   
  7. return True   
  8. app = App()   
  9. app.MainLoop()   
  10. #wxDemo.py   
  11. import wx   
  12. class App(wx.App):   
  13. def OnInit(self):   
  14. frame = wx.Frame(parent=None, title='Bare')   
  15. frame.Show()   
  16. return True   
  17. app = App()   
  18. app.MainLoop()  
  19.  

Compile the compilation code for py2exe:

Python code

 
 
  1. #setup.py   
  2. from distutils.core import setup   
  3. import py2exe   
  4. setup(windows=["wxDemo.py"])   
  5. #setup.py   
  6. from distutils.core import setup   
  7. import py2exe   
  8. setup(windows=["wxDemo.py"])  
  9.  

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. The following describes how to develop a windows program using python.
 

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.