Python Forum

Full Version: Tkinter parameter question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am a self-taught Tkinter user and, thank you, all is going well.
But I have a question in the realm of widget parameters.

Why is it that sometimes you have to write : (...., bg = 'orange', ...)
and somewhere else : (.... , state = DISABLED, ...)

Why not : ... state = 'disabled' ...

There are other examples.
It would be more consistent, although i suspect that the Tkinter folk
had good reasons. I would like to know them :-)

thx,
Paul
tkinter.DISABLED is a constant defined in the tkinter package whose value is 'disabled',
so you could use state='disabled' and it would work the same.
However, the naming convention in python for constants is
Quote:Constant names must be fully capitalized
all constants can be found at https://github.com/python/cpython/tree/m...nstants.py

colors on the other hand are used across many packages including tkinter. The 'standard' is to use CamelCase see: https://www.w3schools.com/colors/colors_names.asp however case is not strictly adhered to in all applications, therefore even though 'Orange' is 'standard' 'orange' will usually work.
pynche is the python color and hue editor defines all colors in a text file if you want a list, they can be found here: https://github.com/python/cpython/blob/m...colors.txt
OK, clear !

thx,
Paul