Home > Backend Development > Python Tutorial > Python基于Tkinter的HelloWorld入门实例

Python基于Tkinter的HelloWorld入门实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 11:18:37
Original
1691 people have browsed it

本文实例讲述了Python基于Tkinter的HelloWorld入门实例。分享给大家供大家参考。具体分析如下:

初学Python,打算做几个Tkinter的应用来提高。

刚学的HelloWorld,秀一下。我用Python3.2的,Windows版本的。

源代码如下:

#导入sys和tkinter模块 
import sys, tkinter 
#创建主窗口 
root = tkinter.Tk() 
root.title("HelloWorld") 
root.minsize(200, 100) 
#创建标签 
tkinter.Label(root, text="HelloWorld").pack() 
#创建按钮并把命令绑定到退出 
tkinter.Button(root, text="Exit", command=sys.exit).pack() 
#启动主循环 
root.mainloop()

Copy after login

运行截图如下:

希望本文所述对大家的Python程序设计有所帮助。

Related labels:
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