Python使用tkinter库创建图形界面HelloWorld
2011-12-13 18:01
661 查看
备注
tkinter是python自带的GUI库。若要追求功能强大的跨平台开发,建议使用QT与wxWidgets的wxPython版本一、源码:
from tkinter import * class Application(Frame): def say_hi(self): print("hi there, everyone!") def createWidgets(self): self.QUIT = Button(self) self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "red" self.QUIT["command"] = self.quit self.QUIT.pack({"side": "left"}) self.hi_there = Button(self) self.hi_there["text"] = "Hello", self.hi_there["command"] = self.say_hi self.hi_there.pack({"side": "left"}) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() root = Tk() app = Application(master=root) app.mainloop() root.destroy()
二、结果预览:
相关文章推荐
- Python中使用Tkinter模块创建GUI程序实例
- Python中使用Tkinter模块创建GUI程序实例
- Python使用类来创建对象
- Python(16)python使用tkinter实现一个简单的计算器
- 2-1. Creating a Simple Model 使用图形界面设计器创建一个简单的模型
- 在 Windows Azure 网站上使用 Django、Python 和 MySQL:创建博客应用程序
- 使用python创建cocos2dx 项目
- Python使用Threading模块创建线程
- ananconda创建新环境,python 2.7、3.5共存,pycharm 使用conda新环境,win10、linux下通用
- python的tkinter使用
- 我的python学习笔记.创建和使用类
- PyCharm使用-first step(创建并运行第一个python工程)
- 使用Python命令创建jenkins的job
- 使用python自带Venv创建虚拟环境安装多版本python
- 【python爬虫】scrapy框架笔记(一):创建工程,使用scrapy shell,xpath
- cocos2d-x使用python脚本创建项目的简单方法
- 解决python中使用matplotlib时候出现ImportError: No module named _tkinter
- python里使用asyncore创建时间服务客户端
- 创建ROS工作空间使用catkin_make时出现和python编译器有关的编译错误