This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tkinter config() minor documentation bug for shorthand options
Type: behavior Stage: needs patch
Components: Documentation, Tkinter Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, serhiy.storchaka, spirko, terry.reedy
Priority: normal Keywords:

Created on 2021-06-21 23:44 by spirko, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg396301 - (view) Author: Jeff S (spirko) Date: 2021-06-21 23:44
The documentation page https://docs.python.org/3/library/tkinter.html states "Passing the config() method the name of a shorthand option will return a 2-tuple, not 5-tuple."  While config() without argument does return a map that yields references like this, if config() is given the shorthand name as an argument, it follows the reference to the long option name and does yield the full 5-tuple.

To demonstrate the difference:

from tkinter import Tk

Tk().config()['bg']

Tk().config('bg')
msg396551 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-26 14:14
The specific subsection link is
https://docs.python.org/3/library/tkinter.html#setting-options

The outputs
>>> import tkinter as tk
>>> r = tk.Tk()
>>> r.config('bg')
('background', 'background', 'Background', <string object: 'SystemButtonFace'>, 'SystemButtonFace')
>>> r.config()['bg']
('bg', '-background')

I think
"Example:

>>> print(fred.config())
{'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')}

Of course, the dictionary printed will include all the options available and their values. This is meant only as an example."

would be clearer with ellipses instead of the sentence after a misleading output.

"Example key-value pair in the dictionary returned by config():

>>> fred.config()
{..., 'relief': ('relief', 'relief', 'Relief', 'raised', 'groove'), ...}"

The previous code should set the relieve to 'groove' in order for this to make more sense.  Or, instead use example with 2- and 5-tuples.

{..., 'fg': ('fg', '-foreground'), ..., 'foreground': ('foreground', 'foreground', 'Foreground', 'SystemButtonText', 'SystemButtonText'), ...}
---

Side note: the third members of these tuples are reversed.  Bug in tk?
b.config('activebackground')
('activebackground', 'activeBackground', 'Foreground', 'SystemButtonFace', 'SystemButtonFace')
b.config('activeforeground')
('activeforeground', 'activeForeground', 'Background', 'SystemButtonText', 'SystemButtonText')
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88647
2021-06-26 14:14:30terry.reedysetassignee: docs@python
components: + Documentation
versions: + Python 3.11, - Python 3.6, Python 3.9
nosy: + serhiy.storchaka, docs@python, terry.reedy

messages: + msg396551
stage: needs patch
2021-06-21 23:44:11spirkocreate