What is python gui programming (tkinter)? Example showing Python tkinter tutorial

Tomorin
Release: 2018-08-17 14:42:22
Original
2511 people have browsed it

In the previous article, we learned about Python CGI programming. In this article, we will introduce Python gui programming (tkinter) and attach the Python tkinter tutorial.
Python provides multiple graphical development interface libraries. Several commonly used Python GUI libraries are as follows:

Tkinter: Tkinter module(Tk interface ) is the interface to Python's standard Tk GUI toolkit. Tk and Tkinter can be used on most Unix platforms, as well as on Windows and Macintosh systems. Subsequent versions of Tk8.0 can implement local window styles and run well on most platforms.

wxPython: wxPython is an open source software and an excellent GUI graphics library for the Python language, allowing Python programmers to easily create complete and fully functional GUI user interfaces.

Jython: Jython programs can be seamlessly integrated with Java. In addition to some standard modules, Jython uses Java modules. Jython has almost all the modules in 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 the python installation package, you can import the Tkinter library after installing Python, and IDLE is also written in Tkinter. Tkinter can still handle the simple graphical interface easily.

import tkinter
Copy after login

Create a GUI program

1. Import the Tkinter module

2. Create a control

3. Specify the master of this control, that is, this control belongs to Which

4. Tell GM (geometry manager) that a control has been generated.

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import Tkinter
top = Tkinter.Tk()
# 进入消息循环
top.mainloop()
Copy after login

The execution result of the above code is as follows:

What is python gui programming (tkinter)? Example showing Python tkinter tutorial


The above is the detailed content of What is python gui programming (tkinter)? Example showing Python tkinter tutorial. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template