您的位置:首页 > 编程语言 > Python开发

python 3.0 GUI界面例子

2011-11-14 22:51 579 查看
我在一个Python 3.2的文档中,看到以下例子。

代码如下所示:

__author__ = 'minggxu9'
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()


里面有个hello按钮和一个关闭按钮。
里面的代码,不用多说。你懂的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: