python tkinter

来源:互联网 发布:使用淘宝联盟微信号 编辑:程序博客网 时间:2024/03/29 02:52

参考资料:

文档说明:http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

有不少例子的网站:http://www.python-course.eu/tkinter_checkboxes.php


tkinter 是 python的GUI,python有很多GUI,之所以选择他是因为python天然自带,比较省事。

 一个简单的tkinter示例

import Tkinter as tkclass Application(tk.Frame):    # 必须要从Frame继承,frame是一个安排control布局的容器    def __init__(self, master = None):        tk.Frame.__init__(self, master)  # 调用parent的构造函数        self.grid()#         self.createWidgets()    def createWidgets(self):        self.quitButton = tk.Button(self, text = 'quit', command = self.quit)  # button作为frame的child来构造        self.quitButton.grid()# 将button以grid的样式添加到Frame中app = Application()app.master.title("sample application")app.mainloop()    #启动循环,等待鼠标和键盘的输入

之前用过MFC QT IOS,所有的这些关于GUI开发的库都有通用的规则,无非是Control的建立,Control事件的相应,Control的布局,事件循环,从上面四个角度来理解,tkinter半天就能掌握好。


0 1
原创粉丝点击