`
byebyegov5qq
  • 浏览: 1215667 次
文章分类
社区版块
存档分类
最新评论

Tk GUI toolkit: A Simple Hello World Program

 
阅读更多
一个有关利用Python来编写GUI程序的小范例
fromTkinterimport*

classApplication(Frame):
defsay_hi(self):
print"hithere,everyone!"

defcreateWidgets(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()

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics