- 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.
推薦閱讀
- 觸·心:DT時代的大數(shù)據(jù)精準(zhǔn)營銷
- 案例式C語言程序設(shè)計
- The Android Game Developer's Handbook
- Designing Hyper-V Solutions
- The DevOps 2.4 Toolkit
- 速學(xué)Python:程序設(shè)計從入門到進階
- 創(chuàng)意UI:Photoshop玩轉(zhuǎn)APP設(shè)計
- Python商務(wù)數(shù)據(jù)分析(微課版)
- Getting Started with Python
- Java Web開發(fā)實例大全(基礎(chǔ)卷) (軟件工程師開發(fā)大系)
- Learning Kotlin by building Android Applications
- 交互設(shè)計師成長手冊:從零開始學(xué)交互
- Node.js 6.x Blueprints
- 和孩子一起學(xué)編程:用Scratch玩Minecraft我的世界
- Spring Boot學(xué)習(xí)指南:構(gòu)建云原生Java和Kotlin應(yīng)用程序