- Tkinter GUI Application Development Cookbook
- Alejandro Rodas de Paz
- 192字
- 2021-08-27 19:43:58
Getting ready
We will take the following program as an example:
from tkinter import * root = Tk() btn = Button(root, text="Click me!") btn.config(command=lambda: print("Hello, Tkinter!")) btn.pack(padx=120, pady=30) root.title("My Tkinter app") root.mainloop()
It creates a main window with a button that prints Hello, Tkinter! in the console each time it is clicked. The button is placed with a padding of 120px in the horizontal axis and 30px in the vertical axis. The last statement starts the main loop, which processes user events and updates the GUI until the main window is destroyed:

You can execute the program and verify that it is working as expected. However, all our variables are defined in the global namespace, and the more widgets you add, the more difficult it becomes to reason about the parts where they are used.
These maintainability issues can be addressed with basic OOP techniques, which are considered good practice in all types of Python programs.
- Software Defined Networking with OpenFlow
- Magento 2 Development Cookbook
- PHP網(wǎng)絡(luò)編程學(xué)習(xí)筆記
- 深入淺出DPDK
- JS全書:JavaScript Web前端開發(fā)指南
- Creating Stunning Dashboards with QlikView
- HTML 5與CSS 3權(quán)威指南(第3版·上冊)
- Test-Driven Machine Learning
- Test-Driven Development with Django
- Java程序員面試筆試寶典(第2版)
- 深入理解C指針
- CRYENGINE Game Development Blueprints
- 零基礎(chǔ)學(xué)Python編程(少兒趣味版)
- SQL Server 2008中文版項目教程(第3版)
- Mastering jQuery Mobile