Skip to content

IDLE: move Aqua context menu code to maxosx #71449

Closed

Description

@terryjreedy
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']

    Activity

    1. terryjreedy commented on Jun 8, 2016

      @terryjreedy
      MemberAuthor

      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?

    2. self-assigned this
      on Jun 8, 2016
    3. serhiy-storchaka commented on Jun 8, 2016

      @serhiy-storchaka
      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".

    4. terryjreedy commented on Jun 8, 2016

      @terryjreedy
      MemberAuthor

      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?

    5. serhiy-storchaka commented on Jun 8, 2016

      @serhiy-storchaka
      Member

      I think you can just use bindtags().

      button = Button(...)
      bindtags = button.bindtags()
      button.bindtags(bindtags[:1] + ['MyButton'] + bindtags[1:])
      root.bind_class('MyButton', ...)
    6. terryjreedy commented on Jun 8, 2016

      @terryjreedy
      MemberAuthor

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

    7. python-dev commented on Jun 8, 2016

      python-devmannequin
      Mannequin

      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

    8. terryjreedy commented on Jun 9, 2016

      @terryjreedy
      MemberAuthor

      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.

    9. python-dev commented on Jun 11, 2016

      python-devmannequin
      Mannequin

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

    10. terryjreedy commented on Jun 11, 2016

      @terryjreedy
      MemberAuthor

      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.

    11. terryjreedy commented on Jun 12, 2016

      @terryjreedy
      MemberAuthor

      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.

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions