Home  >  Article  >  Backend Development  >  How to import tkinter in python

How to import tkinter in python

(*-*)浩
(*-*)浩Original
2019-06-27 13:33:089371browse

Python GUI Programming (Tkinter)

How to import tkinter in python

Python provides multiple graphical development interface libraries. This article introduces the Tkinter library (recommended learning: Python video tutorial

Tkinter: The Tkinter module (Tk interface) is the interface of 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 implement local window styles and run well on most platforms.

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. .

Note: The library name used by Python3.x version is tkinter, that is, the first letter T is lowercase.

import tkinter

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.

Examples

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

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to import tkinter in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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