A Simple Hello World Program

A Simple Hello World Program


<HelloWorld gadget image>(Windows上長這樣)


參閱 the hello-world注意事項總結

  1. from Tkinter import *
  2. class Application(Frame):
  3. def say_hi(self):
  4. print “hi there, everyone!”
  5. def createWidgets(self):
  6. self.QUIT = Button(self)
  7. self.QUIT[“text”] = “QUIT”
  8. self.QUIT[“fg”] = “red”
  9. self.QUIT[“command”] = self.quit
  10. self.QUIT.pack({“side”: “left”})
  11. self.hi_there = Button(self)
  12. self.hi_there[“text”] = “Hello”,
  13. self.hi_there[“command”] = self.say_hi
  14. self.hi_there.pack({“side”: “left”})
  15. def __init__(self, master=None):
  16. Frame.__init__(self, master)
  17. self.pack()
  18. self.createWidgets()
  19. app = Application()
  20. app.mainloop()

[ Next: Tkinter 類別概述 | 內容 ]

感謝你看到這裡,很快就可以離開了,但最好的獎勵行動就是按一下幫我分享或留言,感恩喔~

點我分享到Facebook

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *