Summary of the Python program learning process

Source: Internet
Author: User

When learning Python programs, you need to pay attention to some issues, such as problems in code programming and debugging. These issues must be carefully and carefully understood. Before learning Python programs, you need to thoroughly understand what Python is, and how it is formed.

Although the above implementation functions are very simple, we have indeed established a server of our own and a server that provides services according to the defined protocol. Is development fast? As described on the Twisted website, Develop servers at lightning speed (lightning speed ).

As long as the specific Protocol is further extended, a powerful server can be established. The Twisted function mentioned here is only the tip of the iceberg of this treasure, and it will not be further elaborated here. If you are interested, you can get more information from Twisted's website.

But don't forget that wxPython has no restrictions on the. NET platform. At the same time, do you think of Frame, App, and Doc classes in MFC from the names of wxSimpleApp and wxFrame? Yes, wxPython implements MVC in the same way, making the entire GUI code clearer and easier to maintain. If you are not addicted to it, it is too simple, then let's look at a richer one:

 
 
  1. from wxPython.wx import *  
  2. ID_ABOUT=101 
  3. ID_EXIT=110 
  4. class MainWindow(wxFrame):  
  5.     def __init__(self,parent,id,title):  
  6.         wxFrame.__init__(self,parent,wxID_ANY, title, size = (400,200), style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)  
  7.         self.control = wxTextCtrl(self, 1, style=wxTE_MULTILINE)  
  8.           
  9.         filemenu= wxMenu()  
  10.         filemenu.Append(ID_ABOUT, "&About"," Information about this program")  
  11.         filemenu.AppendSeparator()  
  12.         filemenu.Append(ID_EXIT,"E&xit"," Terminate the program")  
  13.  
  14.         menuBar = wxMenuBar()  
  15.         menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar  
  16.         self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame content.  
  17.         EVT_MENU(self, ID_ABOUT, self.OnAbout)   
  18.         EVT_MENU(self, ID_EXIT, self.OnExit)    
  19.         self.Show(true)  
  20.  
  21.     def OnAbout(self,e):  
  22.         d= wxMessageDialog( self, " A sample editor  "  
  23.                             " in wxPython","About Sample Editor", wxOK)  
  24.                             
  25.         d.ShowModal()   
  26.         d.Destroy()   
  27.  
  28.     def OnExit(self,e):  
  29.         self.Close(true)  # Close the frame.  
  30.  
  31. app = wxPySimpleApp()  
  32. frame = MainWindow(None, -1, "Sample editor")  
  33. app.MainLoop() 

In the above Code, the MainWindow class inherits wxFrame and adds a wxTextCtrl Control for this frame. It also adds a menu and event processing for the menu item. Is it concise? Go to the Python program learning website to get more information. The above code is derived from the Getting Started of the wxPython website.

In addition to developing the GUI in this way, you can also use the Python program learning and CLR collaboration capabilities, or call the WinForms API to easily develop the GUI, it is even an interactive development. For details, refer to IronPython's dad Jim's blog. The above is an interesting Post.

  1. How to embed Python into C ++ applications?
  2. In-depth discussion of Ruby and Python syntax comparison
  3. Introduction to Python
  4. Python Learning Experience: version, IDE selection and coding Solutions
  5. Analysis of Python GIL and thread security

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.