Python Forum
Tkinter parameter question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter parameter question
#1
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
Reply
#2
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
Reply
#3
OK, clear !

thx,
Paul
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner question re: Tkinter geometry return2sender 3 906 Jun-19-2023, 06:19 PM
Last Post: deanhystad
  Tkinter GUI question texan1836 3 1,825 Apr-13-2023, 03:12 AM
Last Post: deanhystad
  simple tkinter question function call not opening image gr3yali3n 5 3,307 Aug-02-2022, 09:13 PM
Last Post: woooee
  [Tkinter] question for a tkinter dialog box RobertAlvarez424 2 2,206 Aug-25-2021, 03:08 PM
Last Post: RobertAlvarez424
  Python tkinter question tablet Nick_tkinter 8 4,930 Mar-04-2021, 10:44 PM
Last Post: Larz60+
  tkinter slider question Nick_tkinter 1 2,436 Feb-22-2021, 01:31 PM
Last Post: deanhystad
  [Tkinter] Noob question:Using pyttsx3 with tkinter causes program to stop and close, any ideas? Osman_P 4 5,233 Nov-14-2020, 10:51 AM
Last Post: Osman_P
  question on tkinter canvas PhotoImage gr3yali3n 1 2,106 Sep-05-2020, 12:18 PM
Last Post: Larz60+
  What units does the width parameter of a tkinter Listbox use? Pedroski55 2 5,455 Jul-04-2020, 08:17 AM
Last Post: deanhystad
  Newbie question with Tkinter Entry mariolopes 2 2,202 Oct-12-2019, 11:02 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020