ANN: Thinking in Tkinter
steve at ferg.org
Fri Sep 13 08:32:04 EDT 2002
> I can't really say WHY using a class structure is desirable.
It is coming back to me now.
As I was working on easygui.py (http://www.ferg.org/easygui/), I
noticed two things. (1) I was using global variables a lot. (2) I had
several GUI "chunks" in one Python program, and when they were all at
the same level, the code was really unstructured. Very hard to
Granted, a lot of my confusion was simply newbie confusion. But I
thought that the next Tkinter development I did, I would see if
structuring the GUI component into classes would help with these
problems. Even in the limited development I've been doing for
"Thinking in Tkinter", it seems to me that: (1) being able to refer to
"self." variables removes the need to make so many variables global.
(2) Grouping the GUI material into classes really helps bring some
structure to the program that it didn't have before. I suspect that
the importance of this (which may not be that obvious in small
programs) will become overwhelmingly obvious in larger and more
elaborate GUIs. One of my "to do" items is to test this hypothesis by
re-writing easygui.py using a class structure.
So right now, my hypothesis is that -- although Tkinter technology
does not *require* you to structure your GUI as class -- doing so is
probably desirable simply from the standpoint of making a large
program more manageable.
More information about the Python-list