Tkinter docs?

Christian Gollwitzer auriocus at gmx.de
Wed May 24 02:48:44 EDT 2023


Am 24.05.23 um 03:18 schrieb Rob Cliffe:
> I have recently started converting a large project to tkinter, starting 
> with zero knowledge of tkinter.  (You are free to think: BAD IDEA. 😁)

Welcome to the awesome world of GUI development.

>      I was writing a subclass of the Checkbutton class (tkinter's name 
> for what I call a checkbox).  I needed to be able to (1) set (2) clear 
> (3) interrogate the checked state.  This is easy to do if you associate 
> a "variable" with each Checkbutton instance, as seems to be usual 
> tkinter practice.  ("variable" is not a variable in the usual sense, but 
> an object provided by tkinter that is linked to a GUI object (such as a 
> Checkbutton), so that when the GUI object changes, the value of the 
> "variable" changes, and vice versa.) However, I decided that I wanted to 
> dispense with the variable, if possible.  

As you found out the hard way, it is possible, but then you dive into 
the internals of how the widgets work - usually you don't want to know 
that. Also, this bit differs between Tk and Ttk widgets.


> [...] lengthe description of Checkbutton internals


In GUI programming, you will meet a bag of concepts that you haven't 
seen in sequential programming before. To make it worse, every GUI 
toolkit brings its own new set of concepts to the table. Maybe it is 
helpful to work through a Tk tutorial first. This is a good one:

	http://tkdocs.com/tutorial/index.html

Similarly to the tutorial I would suggest to stick with the ttk widgets. 
Those are an "update" (> 10 years ago) to the tk widgets and are 
supposed to provide sensible defaults matching the users experience with 
native GUI elements. There are only 3 widgets where you must use a Tk 
widget, this is Text (for multiline formatted text entry), Canvas (for 
2D drawings), and Toplevel (for new windows/ popups etc.)

	Christian



More information about the Python-list mailing list