- Tkinter GUI Programming by Example
- David Love
- 90字
- 2021-08-27 18:49:08
Fixing our application
Let's get our Hello World application working as intended again using our new knowledge of Tkinter variables. After setting the title, change the label_text property as follows:
self.label_text = tk.StringVar()
self.label_text.set("Choose One")
Now, alter our other two methods like so:
def say_hello(self):
self.label_text.set("Hello World")
def say_goodbye(self):
self.label_text.set("Goodbye! \n (Closing in 2 seconds)")
self.after(2000, self.destroy)
Once again, run the application and click both buttons. Everything should now be all working as before.
Great! We now know how to take advantage of Tkinter's special variables, and it's super easy.
推薦閱讀
- Java程序設(shè)計(jì)與開發(fā)
- Mastering AWS Lambda
- Learn Type:Driven Development
- Microsoft Dynamics 365 Extensions Cookbook
- 動手玩轉(zhuǎn)Scratch3.0編程:人工智能科創(chuàng)教育指南
- Learning Selenium Testing Tools(Third Edition)
- Java面向?qū)ο蟪绦蛟O(shè)計(jì)
- Python+Tableau數(shù)據(jù)可視化之美
- IDA Pro權(quán)威指南(第2版)
- 會當(dāng)凌絕頂:Java開發(fā)修行實(shí)錄
- Mastering Apache Camel
- Mastering ASP.NET Web API
- AI輔助編程Python實(shí)戰(zhàn):基于GitHub Copilot和ChatGPT
- Web前端開發(fā)精品課:HTML5 Canvas開發(fā)詳解
- Jenkins 2.x實(shí)踐指南