- 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.
- Web應(yīng)用系統(tǒng)開發(fā)實踐(C#)
- 精通API架構(gòu):設(shè)計、運維與演進(jìn)
- Java:Data Science Made Easy
- Mastering Ubuntu Server
- YARN Essentials
- 機(jī)械工程師Python編程:入門、實戰(zhàn)與進(jìn)階
- Monitoring Elasticsearch
- AppInventor實踐教程:Android智能應(yīng)用開發(fā)前傳
- Getting Started with LLVM Core Libraries
- .NET 4.5 Parallel Extensions Cookbook
- 深入理解BootLoader
- 人人都能開發(fā)RPA機(jī)器人:UiPath從入門到實戰(zhàn)
- Android技術(shù)內(nèi)幕(系統(tǒng)卷)
- ASP.NET Core 2 High Performance(Second Edition)
- R語言數(shù)據(jù)分析從入門到實戰(zhàn)