New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDLE: move Aqua context menu code to maxosx #71449
Comments
Put the AquaTk code added to pyshell.main in bpo-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? |
"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". |
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 bpo-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? |
I think you can just use bindtags(). button = Button(...)
bindtags = button.bindtags()
button.bindtags(bindtags[:1] + ['MyButton'] + bindtags[1:])
root.bind_class('MyButton', ...) |
[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. |
New changeset 09ec7f7322b5 by Terry Jan Reedy in branch 'default': |
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 bpo-5124. |
New changeset 374dd14cf0e5 by Ned Deily in branch 'default': |
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. |
Changeset d8a2b6efdd4a, bpo-27239, adds a test of setupApp in test_macosx that fails on any system, in particular mine, when Ned's fix is undone. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: