Skip to content
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

Closed
terryjreedy opened this issue Jun 8, 2016 · 10 comments
Closed

IDLE: move Aqua context menu code to maxosx #71449

terryjreedy opened this issue Jun 8, 2016 · 10 comments
Assignees
Labels
topic-IDLE type-feature A feature request or enhancement

Comments

@terryjreedy
Copy link
Member

BPO 27262
Nosy @terryjreedy, @serhiy-storchaka
Files
  • aqua_context.diff
  • 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 = 'https://github.com/terryjreedy'
    closed_at = <Date 2016-06-12.19:55:45.573>
    created_at = <Date 2016-06-08.02:21:23.086>
    labels = ['expert-IDLE', 'type-feature']
    title = 'IDLE: move Aqua context menu code to maxosx'
    updated_at = <Date 2019-03-23.20:00:08.223>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2019-03-23.20:00:08.223>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-06-12.19:55:45.573>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2016-06-08.02:21:23.086>
    creator = 'terry.reedy'
    dependencies = []
    files = ['43290']
    hgrepos = []
    issue_num = 27262
    keywords = ['patch']
    message_count = 10.0
    messages = ['267760', '267775', '267799', '267801', '267876', '267877', '268061', '268194', '268198', '268398']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27262'
    versions = ['Python 3.6']

    @terryjreedy
    Copy link
    Member Author

    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?

    @terryjreedy terryjreedy self-assigned this Jun 8, 2016
    @terryjreedy terryjreedy added the type-feature A feature request or enhancement label Jun 8, 2016
    @serhiy-storchaka
    Copy link
    Member

    "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".

    @terryjreedy
    Copy link
    Member Author

    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?

    @serhiy-storchaka
    Copy link
    Member

    I think you can just use bindtags().

    button = Button(...)
    bindtags = button.bindtags()
    button.bindtags(bindtags[:1] + ['MyButton'] + bindtags[1:])
    root.bind_class('MyButton', ...)

    @terryjreedy
    Copy link
    Member Author

    [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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 8, 2016

    New changeset 09ec7f7322b5 by Terry Jan Reedy in branch 'default':
    Issue bpo-27262: move Aqua unbinding code, which enable context menus, to maxosx.
    https://hg.python.org/cpython/rev/09ec7f7322b5

    @terryjreedy
    Copy link
    Member Author

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 11, 2016

    New changeset 374dd14cf0e5 by Ned Deily in branch 'default':
    Issue bpo-27262: fix missing parameter typo
    https://hg.python.org/cpython/rev/374dd14cf0e5

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy
    Copy link
    Member Author

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-IDLE type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants