码迷,mamicode.com
首页 > 编程语言 > 详细

python tkinter

时间:2014-09-25 22:40:28      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   os   ar   sp   2014   on   

http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

 一个简单的tkinter示例

import Tkinter as tk
class 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半天就能掌握好。


python tkinter

标签:style   blog   http   io   os   ar   sp   2014   on   

原文地址:http://blog.csdn.net/wangeen/article/details/39557569

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!