aricb Too often I find that when I write Tk code to do anything non-trivial, I end up with a sprawling disaster that is a pain to modify or even understand six months later. As I'm sure other programmers have encountered this problem, I searched for some guidelines on the Wiki and on the web. I'll share what I found below. However, I came to the conclusion that much more could (and should) be said on this topic.
Here's what I've found so far (please add to this list):
Tom Tromey's style guide [L1 ] has an excellent section on Tk. By contrast, Ray Johnson's Tcl style guide [L2 ], which has become the de facto standard for Tcl, doesn't address Tk specifically.
A handful of wiki pages address this topic:
Here's what little I currently do to make my code more readable. Please share any reactions to these:
grid [text .mytoplevel.text] -row 0 -column 0
However, when I have to specify lots of options for the widget and/or the geometry manager, I end up with long lines which IMHO look bad even if I break them up with backslashes.
Please contribute any principles that help you write Tk code in a more readable, manageable, and/or reusable way.