msg43671 - (view) |
Author: Greg Couch (gregcouch) |
Date: 2003-05-07 20:11 |
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. - Greg Couch |
|
|
msg43672 - (view) |
Author: Jeff Epler (jepler) |
Date: 2003-05-11 14:30 |
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. |
|
|
msg78634 - (view) |
Author: Guilherme Polo (gpolo) *  |
Date: 2008-12-31 17:04 |
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. |
|
|
msg114239 - (view) |
Author: Mark Lawrence (BreamoreBoy) * |
Date: 2010-08-18 16:11 |
A small simple patch that I see no problems with. |
|
|
msg114244 - (view) |
Author: Alexander Belopolsky (belopolsky) *  |
Date: 2010-08-18 16:21 |
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. |
|
|
msg189566 - (view) |
Author: Mark Lawrence (BreamoreBoy) * |
Date: 2013-05-19 02:49 |
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. |
|
|
msg189637 - (view) |
Author: Greg Couch (gregcouch) |
Date: 2013-05-20 04:49 |
We still apply that patch to the Python that we embed in our application and have for the last 10 years :-) |
|
|
msg189674 - (view) |
Author: Mark Lawrence (BreamoreBoy) * |
Date: 2013-05-20 16:40 |
I've attached a patch for Python 3 which I hope is okay as it's my first attempt using TortoiseHg on Windows. |
|
|
msg195928 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2013-08-22 22:02 |
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 .#12345 already exists it try .#123451, .#123452, .#123453, etc. It is impossible restore original name in general case. |
|
|
msg270902 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-07-21 01:58 |
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, #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. |
|
|
msg271130 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-07-24 05:29 |
Issue18686 is reproducible to me. Here is a script based on example. Run it and open the "File" menu. $ python3 .py .#3069298188.#3069298188#3069298252 Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__ return self.func(*args) File ".py", line 24, in entry_focus_lost widget_with_focus = self.focus_get() File "/usr/lib/python3.5/tkinter/__init__.py", line 550, in focus_get return self._nametowidget(name) File "/usr/lib/python3.5/tkinter/__init__.py", line 1204, in nametowidget w = w.children[n] KeyError: '#3069298188' But my patch doesn't help in case of tearoff menu. Detach the "File" menu and hover a mouse on its item. $ ./python .py .#`menu.#`menu#`menu .`menu.`menu .tearoff1 Exception in Tkinter callback Traceback (most recent call last): File "/home/serhiy/py/cpython/Lib/tkinter/__init__.py", line 1712, in __call__ return self.func(*args) File ".py", line 24, in entry_focus_lost widget_with_focus = self.focus_get() File "/home/serhiy/py/cpython/Lib/tkinter/__init__.py", line 692, in focus_get return self._nametowidget(name) File "/home/serhiy/py/cpython/Lib/tkinter/__init__.py", line 1344, in nametowidget w = w.children[n] KeyError: 'tearoff1' |
|
|
msg271131 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-07-24 05:32 |
Following patch tries to handle the case when there are multiple clones (but it doesn't help with tearoff menus). |
|
|
msg397223 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2021-07-09 21:02 |
See #44592, closed as duplicate of this. |
|
|