Introduction to a variety of Python applications

Source: Internet
Author: User
Tags glob

This article describes in detail how a Python application can put data and operation data functions together to make it clearer. Although there is a so-called concept of data hiding, but in python, it is actually a convention that does not directly call the data in the object, but uses a function as a transit.

In fact, it is normal to understand the object orientation. In fact, sometimes it is necessary to use the intermediate sentiment. When can I use function programming? I came up with a channel. Maybe you already feel what object-oriented programming is. In addition, some so-called OO rules do not require syntax support. If you have this idea in mind, what do you think? Can write OO code, no matter what language or syntax you use.

 
 
  1. # setup.py  
  2. from distutils.core import setup  
  3. import glob  
  4. import py2exe  
  5.  
  6. setup(name="myscript",  
  7.       scripts=["myscript.py"],  
  8.       data_files=[("bitmaps",  
  9.                    ["bm/large.gif", "bm/small.gif"]),  
  10.                   ("fonts",  
  11.                    glob.glob("fonts\\*.fnt"))],  

The mysteries of the graphic interface are actually not profound. I believe that many people start learning windows programming by writing a window and trying to understand the message and event-driven model. The general process is like this. The window is painted in pixels. You can think of a window as a window or a set of pixels. It's just like some people say that female looks just like flesh.

In addition, the buttons in the window, the editing of mines and various icons, No matter what looks like an "object", are essentially drivers with applications, libraries, or operating systems that call video cards, use the graphics card function to draw some points on the screen. The so-called "object" has many naming rules, and is generally a control in windows ).

The graphical interface is generally controlled by the mouse and keyboard. The mouse has its own image on the screen, that is, an arrow, of course, you can also adjust this image as another fun thing, it is your freedom ).

The keyboard is generally represented as a dotted box, And the Python application shows that this is the "Focus" of the keyboard. Or the flashing vertical bar in the editing box. The two points share one thing in common, that is, they all have a location to determine the object to be operated. When you click the mouse, you are operating on the space pointed to by the tip of the mouse arrow, and the keyboard press is also directed to the control where the focus is located. What happened?

The process is received by the operating system from the hardware level to the software level. The operating system can know where you click the mouse or keyboard, and whether you press the Left or Right button. The operating system also knows where the current window is located. Based on various information, the operating system can know the window to which the "event" is sent as a "message.

We should be able to understand what an event is, and a message is a struct in C. Several fields contain information about this event, then, like a letter, it is shipped from the operating system to the application where the window is located.

Then the application has a pre-registered "Window Process". The Python application is actually a function used to receive this "letter ". It is actually receiving the passed parameters. Then, make some judgments and respond accordingly. This is the so-called event-driven. Without lengthy Code and all the details, if you really knew nothing about the process before, you would feel very confused. In fact, this story only gives you a perceptual knowledge.

  • How to build a Python development environment correctly
  • Notes for getting started with the Python Module
  • Graphical Python interpreter configuration problems
  • Detailed introduction and analysis of Python build tools
  • Deep description of Python source file nature

In fact, there is no need to worry about many things when using Windows in python. Basically, you only need to give some location parameters to the windows and controls you want, and set the parameters of some text prompts to display the window. Then, the Code tells python to execute this function when the button is pressed, and then the window can respond.

Finally, remember to give a window exit method and everything will be OK. Python applications can save much of their complexity. The cost is a little slow, but I don't believe you can feel it unless your computer doesn't even see vcd smoothly. Therefore, you can safely enjoy this convenience.

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.