Open 21edd26c-470c-43e1-983f-93ac8151efd7 opened 3 years ago
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')
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')
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at = None created_at =
labels = ['3.11', 'type-bug', 'expert-tkinter', 'docs']
title = 'Tkinter config() minor documentation bug for shorthand options'
updated_at =
user = 'https://bugs.python.org/spirko'
```
bugs.python.org fields:
```python
activity =
actor = 'terry.reedy'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation', 'Tkinter']
creation =
creator = 'spirko'
dependencies = []
files = []
hgrepos = []
issue_num = 44481
keywords = []
message_count = 2.0
messages = ['396301', '396551']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'docs@python', 'serhiy.storchaka', 'spirko']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44481'
versions = ['Python 3.11']
```