classification
Title: IDLE: move Aqua context menu code to maxosx
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2016-06-08 02:21 by terry.reedy, last changed 2019-03-23 20:00 by terry.reedy. This issue is now closed.

Files
File name Uploaded Description Edit
aqua_context.diff terry.reedy, 2016-06-08 02:21 review
Messages (10)
msg267760 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-08 02:21
Put the AquaTk code added to pyshell.main in #24801 where it should have gone originally. (My fault, ultimately.)  See aqua_context.diff.  This is a step in factoring main (currently about 170 lines) into a manageable number of function calls.

I will try to add a test that 1. creates an editor window with a 'fixed' root and mocked .right_click_event method, generates a right click, and checks the mock event handler; 2. creates a context menu, etc.

Serhiy, the docstring for .class_bind says "Bind to widgets with bindtag CLASSNAME".  I have not and do not see 'bindtag' defined.  Am I correct that it must refer to a tk widget class, rather than a python tkinter class, or subclass thereof?
msg267775 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-08 04:28
"bindtag" is an arbitrary string. Usually this is a name of Tk widget class of or "all". bindtags() allows to retrieve or set a list of bindtags associated with a widget. By default they are: full path of a widget, name of Tk class of widgets, full path of a toplevel window, "all".
msg267799 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-08 06:53
I am asking because I noticed that every editor windows gets the same set of bindings set and destroyed, (as in the other part of the #24801 patch).  Since events have a widget attribute, using bound methods with a self parameter is not necessary, so all the duplication seems redundant.  But class_binding to Text is too broad.  It there any way to register 'subclasses', similar to the way one can register style options as applying to a subset of, for instance, all Buttons?
msg267801 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-08 07:12
I think you can just use bindtags().

button = Button(...)
bindtags = button.bindtags()
button.bindtags(bindtags[:1] + ['MyButton'] + bindtags[1:])
root.bind_class('MyButton', ...)
msg267876 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-08 18:22
[The light dawns, as the pieces connect together] The pseudoclass 'MyButton' would then consist of all widgets with 'MyButton' inserted into its bindtags list.  Similarly for 'Editor'. I presume that a) tk has the equivalent of a master bind dict mapping bindtags to dicts mapping event sequences strings to event handlers, and b) .bind_class(cname, evseq, func) does the equivalent of "tagdict.get(cname, {})[evseq] = func".

I also notice that the introspective versions of .bind... call will let us discover the pre-defined bindings on difference systems and check our alterations.  Anyway, thanks.  I will experiment when ready to refactor bindings.  In the meanwhile, I will apply the patch and close this.
msg267877 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-08 18:37
New changeset 09ec7f7322b5 by Terry Jan Reedy in branch 'default':
Issue #27262: move Aqua unbinding code, which enable context menus, to maxosx.
https://hg.python.org/cpython/rev/09ec7f7322b5
msg268061 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-09 21:55
I am leaving this open to look into later adding an automated test for this to the new test_editmenu file that will be added for #5124.
msg268194 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-11 06:58
New changeset 374dd14cf0e5 by Ned Deily in branch 'default':
Issue #27262: fix missing parameter typo
https://hg.python.org/cpython/rev/374dd14cf0e5
msg268198 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-11 08:03
I will add a test that calls setupApp, which would have failed with an error.  I will also remove the call to _init_tk_type in setupApp, and let it be called when needed by the first isMacTk function called.  Test code can partly simulate being on a particular type of Mac by setting _tk_type.
msg268398 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-12 19:55
Changeset d8a2b6efdd4a, #27239, adds a test of setupApp in test_macosx that fails on any system, in particular mine, when Ned's fix is undone.
History
Date User Action Args
2019-03-23 20:00:08terry.reedysetcomponents: + IDLE
2016-06-12 19:55:45terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg268398

stage: test needed -> resolved
2016-06-11 08:03:15terry.reedysetmessages: + msg268198
2016-06-11 06:58:26python-devsetmessages: + msg268194
2016-06-09 21:55:25terry.reedysetmessages: + msg268061
2016-06-08 18:37:36python-devsetnosy: + python-dev
messages: + msg267877
2016-06-08 18:22:52terry.reedysetmessages: + msg267876
2016-06-08 07:12:56serhiy.storchakasetmessages: + msg267801
2016-06-08 06:53:27terry.reedysetmessages: + msg267799
2016-06-08 04:28:05serhiy.storchakasetmessages: + msg267775
2016-06-08 02:21:23terry.reedycreate