December 2017
Beginner
412 pages
10h 8m
English
The GUIs we have built so far have not been particularly well structured. Most of the code to construct them has not been modularized in functions, and they have relied on global variables. We can get away with this for very small examples, but if we try to build larger applications this way, they will be difficult to understand and debug.
For this reason, almost all real GUIs are built using classes and objects that tie models, views, and controllers together in one tidy package. In the counter shown next, for example, the application’s model is a member variable of class Counter, accessed using self.state, and its controllers are the methods up_click and quit_click.
| | import tkinter |
| | |
| | class Counter: |
| | """A simple ... |
Read now
Unlock full access