Repository navigation
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
| BPO | 734176 |
|---|---|
| Nosy | @terryjreedy, @abalkin, @serhiy-storchaka |
| Files |
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:
assignee = None
closed_at = None
created_at = <Date 2003-05-07.20:11:52.000>
labels = ['type-bug', 'expert-tkinter']
title = "Make Tkinter.py's nametowidget work with cloned menu widgets"
updated_at = <Date 2021-07-09.21:02:53.288>
user = 'https://bugs.python.org/gregcouch'bugs.python.org fields:
activity = <Date 2021-07-09.21:02:53.288>
actor = 'terry.reedy'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Tkinter']
creation = <Date 2003-05-07.20:11:52.000>
creator = 'gregcouch'
dependencies = []
files = ['5260', '12509', '30320', '31426', '43851']
hgrepos = []
issue_num = 734176
keywords = ['patch']
message_count = 13.0
messages = ['43671', '43672', '78634', '114239', '114244', '189566', '189637', '189674', '195928', '270902', '271130', '271131', '397223']
nosy_count = 6.0
nosy_names = ['jepler', 'terry.reedy', 'belopolsky', 'gregcouch', 'gpolo', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue734176'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']Linked PRs
- gh-38464: Make tkinter nametowidget() work with cloned menus #152336
- [3.15] gh-38464: Make tkinter nametowidget() work with cloned menus (GH-152336) #152349
- [3.14] gh-38464: Make tkinter nametowidget() work with cloned menus (GH-152336) #152350
- [3.13] gh-38464: Make tkinter nametowidget() work with cloned menus (GH-152336) #152351
Reacted by Jesse205
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
gregcouch commentedon May 7, 2003
Tk will clone menu widgets when they are torn off and
it gives them names at are similar to the original
widget's names. The patch extends the nametowidget so
it will return the original widget when given the name
of a cloned widget. We used this patch to provide
balloon help in cloned menus. This patch isn't
perfect, it will fail on clones of clones, but it is a
big help.
This patch was made against the latest CVS version
1.173 of Tkinter.py but works against older
Tkinter.py's too.
jepler commentedon May 11, 2003
Logged In: YES
user_id=2772
I don't believe that the naming convention of cloned menus is actually documented anywhere (it's certainly not documented in menu(n) of tk-8.3.5 as packaged by RedHat. The only promise that the documentation makes is that the clone "is a child of the original". (but that can be violated if "menu clone" is invoked directly:
% menu .m
.m
% .m clone .n
%
)
That said, the convention for automatically generated clones hasn't varied in the versions of Tk I'm aware of (at least 8.2 through 8.4) so it might be reasonable to depend on this.
Does anybody in Python development also keep up with Tcl/Tk development? It might be reasonable to ask them to document the format of automatically generated clone names.
gpolo commentedon Dec 31, 2008
Eh.. old.
Anyway, I have made a patch against trunk now and it should work with
any nested level of cloned menus according to how tk names cloned menus.
BreamoreBoy commentedon Aug 18, 2010
A small simple patch that I see no problems with.
abalkin commentedon Aug 18, 2010
Can someone post a script demonstrating the proposed feature? Is "clones of clones" issue mentioned by OP resolved in the latest patch?
Given that nobody commented on this issue for 7 years, I am skeptical about the utility of this feature.
BreamoreBoy commentedon May 19, 2013
Ten years on does anybody actually care about this? If you do the patch will need reworking as in Python 3 the code exists in lib/tkinter/init.py.
gregcouch commentedon May 20, 2013
We still apply that patch to the Python that we embed in our application
and have for the last 10 years :-)
BreamoreBoy commentedon May 20, 2013
I've attached a patch for Python 3 which I hope is okay as it's my first attempt using TortoiseHg on Windows.
serhiy-storchaka commentedon Aug 22, 2013
bpo-18686 have a script which demonstrates the proposed feature.
However Guilherme's patch is a little wrong. Here is updated patch.
Note that even this patch is not absolute correct, because Tk adds count if new name is not unique. I.e. if .bpo-12345 already exists it try .bpo-123451, .bpo-123452, .bpo-123453, etc. It is impossible restore original name in general case.
terryjreedy commentedon Jul 21, 2016
Serhiy, if you are sure your patch is an improvement, then I think you should commit it without waiting for perfection.
Only the other hand, bpo-18686 does not demonstrate a problem *to me* as it does not fail for me. Does anyone else reproduce the failure on a current non-Windows system? Based just on what I can see, I would be inclined to close this.
serhiy-storchaka commentedon Jul 24, 2016
bpo-18686 is reproducible to me. Here is a script based on bpo-18686 example. Run it and open the "File" menu.
But my patch doesn't help in case of tearoff menu. Detach the "File" menu and hover a mouse on its item.
1 remaining item
terryjreedy commentedon Jul 9, 2021
See bpo-44592, closed as duplicate of this.
ashm-dev commentedon Nov 13, 2025
Ping. Is this issue still relevant?
sharktide commentedon Apr 10, 2026
No activity. Should we close as not planned?
gh-38464: Make tkinter nametowidget() work with cloned menus (GH-152336)
serhiy-storchaka commentedon Jun 26, 2026
Fixed by GH-152336.
nametowidget()now maps the auto-generated name of a cloned menu (a menu used as a menubar or a cascade) back to the original widget instead of raisingKeyError.This resolves the menu-clone case specifically. The more general fix — letting
nametowidget()return a wrapper for any existing Tcl widget (including tear-offs and foreign widgets) by adopting it on its pathname — would subsume this special-casing, and is left as future work.[3.13] gh-38464: Make tkinter nametowidget() work with cloned menus (G…
[3.14] gh-38464: Make tkinter nametowidget() work with cloned menus (G…
[3.15] gh-38464: Make tkinter nametowidget() work with cloned menus (G…