The previous article we learned about Python CGI programming, this article we will introduce
Python GUI Programming (Tkinter)and attached
Python tkinter Tutorial.
Python provides a library of multiple graphical development interfaces, several common Python GUI libraries are as follows:
Tkinter: The Tkinter module (TK interface) is the interface for Python's standard Tk GUI toolkit. Tk and Tkinter can be used on most Unix platforms and can also be applied to Windows and Macintosh systems. Subsequent versions of Tk8.0 can be implemented in a native window style and run well on most platforms.
Wxpython:wxpython is an open source software, a good set of GUI graphics libraries in the Python language, allowing Python programmers to easily create a complete, functional GUI user interface.
The Jython:jython program can be seamlessly integrated with Java. In addition to some standard modules, Jython uses Java modules. Jython has almost all the modules in the standard Python that do not depend on the C language. For example, Jython's user interface will use SWING,AWT or SWT. Jython can be dynamically or statically compiled into Java bytecode.
Tkinter programming
Tkinter is the standard GUI library for Python. Python uses Tkinter to quickly create GUI applications.
Since Tkinter is built into Python's installation package, as long as Python is installed to import the Tkinter library, and IDLE is also written in Tkinter, for a simple graphical interface Tkinter can handle it.
Import Tkinter
Create a GUI program
1. Import Tkinter Module
2. Create a control
3. Specify the master of this control, that is, which one of the controls belongs to
4. Tell GM (geometry Manager) that a control has been generated.
#!/usr/bin/python#-*-coding:utf-8-*-import tkintertop = tkinter.tk () # Enter message loop Top.mainloop ()
The above code executes results such as: