Children's Python programming _ Part 16: graphical interface development

Run the program on the computer program is generally divided into command line and graphical interface program, such as: pip install Python command-party modules, software version management git command belong command line program; Most software uses a graphical interface such as Windows of Word, Excel, etc. drawing software is a graphical user interface, referred to as the GUI.

In the graphical user interface, the user can obtain information from the dialog box and other components of the pattern with the mouse operation menu, button or the like graphical components. Achieve graphical interface processes and production methods game interface is similar: After initialization tool, enter the main loop receiving user event, and displayed, feedback processing until the program exits before the end of the main loop. And rendering the game interface is different, the game interface graphics, mouse events require developers to write programs handle, and a graphical user interface exists has achieved the draw and respond to events buttons, text boxes, call these controls use that is It can reduce the workload of writing programs.

Graphical interface principles are the same in any programming language, this lecture by Python GUI programming, introduces the basic concepts of the graphical interface and simple usage: commonly used controls, layout methods, event handling.

Getting 16.1 GUI

Python is often used Tkinter graphical user interface development, Tcl is a "tool control language" acronym. Tk is Tcl "graphic toolbox" of expansion, while Tkinter is Tk interface acronym, meaning that TK interface.

Tkinter Anaconda has been installed, you can use directly in Windows, in Linux you need to use apt to install python3-tk package.

16.1.1 Basic Concepts

Before learning specific programming, to understand some basic concepts.

1. Controls

Controls also called components, is the most basic part of the graphical user interface, commonly used controls are: buttons, text boxes, labels, forms, and so on.

2. container

Control is a special container which can accommodate the other controls, such as windows, dialog boxes belong to the container.

3. layout

The layout is a method of controlling the size and position of the controls in the container.

4. Event Processing

Events can be identified program operation, such as: press the button to select a radio button or check box, close the program and the like, often require developers to events handling, a response

Guess you like

Origin blog.csdn.net/xieyan0811/article/details/104374887