Skip to content

IDLE goto should use query.Query subclass #71302

Description

@terryjreedy
BPO 27115
Nosy @terryjreedy, @serhiy-storchaka, @mlouielu, @miss-islington
PRs
  • bpo-27115: Move IDLE Query error blanking #18868
  • [3.8] bpo-27115: Move IDLE Query error blanking (GH-18868) #18869
  • [3.7] bpo-27115: Move IDLE Query error blanking (GH-18868) #18870
  • bpo-27115: Use Query subclass for IDLE editor Goto #18871
  • [3.8] bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871) #18886
  • [3.7] bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871) #18887
  • 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 2020-03-10.01:07:06.940>
    created_at = <Date 2016-05-24.23:26:29.279>
    labels = ['expert-IDLE', 'type-bug', '3.7']
    title = 'IDLE goto should use query.Query subclass'
    updated_at = <Date 2020-03-10.01:07:06.939>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2020-03-10.01:07:06.939>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2020-03-10.01:07:06.940>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2016-05-24.23:26:29.279>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 27115
    keywords = ['patch']
    message_count = 18.0
    messages = ['266289', '268186', '268193', '268197', '294547', '294735', '294806', '294812', '294814', '363476', '363673', '363687', '363692', '363693', '363694', '363771', '363793', '363794']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'serhiy.storchaka', 'louielu', 'miss-islington']
    pr_nums = ['18868', '18869', '18870', '18871', '18886', '18887']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27115'
    versions = ['Python 3.6', 'Python 3.7']

    Activity

    1. terryjreedy commented on May 24, 2016

      @terryjreedy
      MemberAuthor

      On Win 10, Python 3.5 or 3.6, IDLE Shell or Editor with at least a few lines of text: hit Alt-G to open 'Goto' window. Enter a line # other than the current one. Hit <Return>. Cursor moves to line enter, though it shrinks to one pixel wide from two pixels. Line:col in status bar is updated.

      Instead of hitting return, click [OK] button. Same thing happens except that status bar line:col is NOT updated. Here is relevant code in EditorWindow, about line 610

          def goto_line_event(self, event):
              text = self.text
              lineno = tkSimpleDialog.askinteger("Goto",
                      "Go to line number:",parent=text)
              text.mark_set("insert", "%d.0" % lineno)
              text.see("insert")

      Changing parent=text to parent=self.root makes no difference. I have not yet tried simulating the interaction with button.invoke and event_generate('<Key-Return>.

      My guess is that one of the last two tk methods is supposed to generate a cursor moved event that is bound to a reset status bar function. But somehow the previous click instead of keypress inhibits the event. So this seems a tk bug. Sethiy, what do you think?

      The workaround for IDLE is to manually invoke a status bar update.

    2. serhiy-storchaka commented on Jun 11, 2016

      @serhiy-storchaka
      Member

      This is not Tkinter issue, but IDLE issue.

      Other similar cases:

      Open search dialog and find something. The status bar is not updated. It is updated only if you close the search dialog.

      Select a text and delete it by a mouse. The status bar is not updated. Choice the Edit|Redo action by a mouse. The status bar is not updated.

    3. terryjreedy commented on Jun 11, 2016

      @terryjreedy
      MemberAuthor

      Okay, will take a look at the status bar code and update mechanism.

    4. self-assigned this
      on Jun 11, 2016
    5. serhiy-storchaka commented on Jun 11, 2016

      @serhiy-storchaka
      Member

      If you close the Goto dialog by pressing <Return>, the KeyRelease event is sent to the editor window. This triggers the <<set-line-and-column>> event.

    6. mlouielu commented on May 26, 2017

      mlouielumannequin
      Mannequin

      We can solve this problem by two ways.

      One is to add set_line_and_column() to the end of goto_line_event(), but this will make Return trigger set_line_and_column twice.

      Another is to change the bind event in simpledialog from "<Return>" to "<KeyRelease-Return>" to prevent editor use the KeyRelease event. But I think this will have some backward-compatibility problem, maybe we should add a parameter to control buttonbox bind on "<Return>" or "<KeyRelease-Return>".

      Then we can add set_line_and_column() to the end of the goto_line_event(), and have no problem about trigging twice.

    7. terryjreedy commented on May 30, 2017

      @terryjreedy
      MemberAuthor

      We should not change simpledialog.py, but we could change bindings after import.

      However, since last summer, we can instead replace simpledialog.py with subclasses of ttk-using query.Query, with custom validators. editor.py uses askinterger for indent width, columns/tab, and goto line number. Iomenu uses askstring for encoding. I have already planned to use Query for the line# box.

    8. changed the title [-]IDLE/tkinter: in simpledialog, <Return> != [OK] click[/-] [+]IDLE: replace used of tkinter simpledialog with query.Query[/+] on May 30, 2017
    9. changed the title [-]IDLE: replace used of tkinter simpledialog with query.Query[/-] [+]IDLE: replace uses of tkinter simpledialog with query.Query[/+] on May 30, 2017
    10. mlouielu commented on May 31, 2017

      mlouielumannequin
      Mannequin

      Ok, changed to query.Query will be good. But the problem still exist, query.Query use "<Key-Return>" to bind at button ok, should it re-bind to "<KeyRelease-Return>" at subclass such as AskInteger(Query) ?

    11. 2 remaining items

    12. mlouielu commented on May 31, 2017

      mlouielumannequin
      Mannequin

      Terry, on the original issue about goto dialog, I would like to propose another approach, instead of using query.Query or simpledialog, how about to make it as a single-window application like sublime text: http://docs.sublimetext.info/en/latest/file_management/file_navigation.html#goto-anything

      I'm now doing some experience on this, and it will push forward for what bpo-30422 want to do.

    13. terryjreedy commented on Mar 6, 2020

      @terryjreedy
      MemberAuthor

      I changed the title to reflect the intended user-visible behavior, which was always the real issue. The original title proposed a solution that would not work. The revised title gave an alternate solution that should not work.

      The discrepancy between clicking [Ok] and and pressing <Return> arises because pressing Enter in the query box leaks <KeyRelease-Return> to the text, which happens to trigger a status bar update. I regard this somewhat accidental side-effect to be a bug to be fixed. Changing the text and status bar are the responsibility of the event handler.

      The line number query box should just return a positive int or None, without side-effect. So we should make sure that Query boxes do not leak key events and create a subclass to get a positive int. But such a replacement is somewhat independent of triggering <<set-line-and-column>>.

      A related issue is that goto does not clear selections. bpo-39844. I may fix that and this with one PR.

    14. changed the title [-]IDLE: replace uses of tkinter simpledialog with query.Query[/-] [+]IDLE goto should always update status bar line & column[/+] on Mar 6, 2020
    15. terryjreedy commented on Mar 8, 2020

      @terryjreedy
      MemberAuthor

      Since PR-18801 fixed the status issue, I am returning this to the box replacement issue.

    16. changed the title [-]IDLE goto should always update status bar line & column[/-] [+]IDLE goto should use query.Query subclass[/+] on Mar 8, 2020
    17. terryjreedy commented on Mar 8, 2020

      @terryjreedy
      MemberAuthor

      The related issue is bpo-39852. Since its PR-18801 fixed the status issue, I am returning this to the box replacement issue.

    18. terryjreedy commented on Mar 9, 2020

      @terryjreedy
      MemberAuthor

      New changeset e53a393 by Terry Jan Reedy in branch 'master':
      bpo-27115: Move IDLE Query error blanking (GH-18868)
      e53a393

    19. miss-islington commented on Mar 9, 2020

      @miss-islington
      Contributor

      New changeset 9d5ed83 by Miss Islington (bot) in branch '3.7':
      bpo-27115: Move IDLE Query error blanking (GH-18868)
      9d5ed83

    20. miss-islington commented on Mar 9, 2020

      @miss-islington
      Contributor

      New changeset f3f0c7a by Miss Islington (bot) in branch '3.8':
      bpo-27115: Move IDLE Query error blanking (GH-18868)
      f3f0c7a

    21. terryjreedy commented on Mar 9, 2020

      @terryjreedy
      MemberAuthor

      New changeset 363fab8 by Terry Jan Reedy in branch 'master':
      bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871)
      363fab8

    22. miss-islington commented on Mar 9, 2020

      @miss-islington
      Contributor

      New changeset cadfe52 by Miss Islington (bot) in branch '3.8':
      bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871)
      cadfe52

    23. miss-islington commented on Mar 9, 2020

      @miss-islington
      Contributor

      New changeset f834535 by Miss Islington (bot) in branch '3.7':
      bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871)
      f834535

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