Title: Tkinter config() minor documentation bug for shorthand options
Type: behavior Stage: needs patch
Components: Documentation, Tkinter Versions: Python 3.11
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 2021-06-26 14:14 by terry.reedy.

Messages (2)
msg396301 - (view) Author: Jeff S (spirko) Date: 2021-06-21 23:44
The documentation page 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


msg396551 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-26 14:14
The specific subsection link is

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

>>> 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?
('activebackground', 'activeBackground', 'Foreground', 'SystemButtonFace', 'SystemButtonFace')
('activeforeground', 'activeForeground', 'Background', 'SystemButtonText', 'SystemButtonText')
Date User Action Args
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