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 goto should use query.Query subclass #71302

Closed
terryjreedy opened this issue May 24, 2016 · 18 comments
Closed

IDLE goto should use query.Query subclass #71302

terryjreedy opened this issue May 24, 2016 · 18 comments
Assignees
Labels
3.7 (EOL) end of life topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

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

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy terryjreedy added topic-tkinter topic-IDLE type-bug An unexpected behavior, bug, or error labels May 24, 2016
    @serhiy-storchaka
    Copy link
    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.

    @terryjreedy
    Copy link
    Member Author

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

    @terryjreedy terryjreedy self-assigned this Jun 11, 2016
    @serhiy-storchaka
    Copy link
    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.

    @mlouielu
    Copy link
    Mannequin

    mlouielu mannequin commented May 26, 2017

    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.

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label May 30, 2017
    @terryjreedy terryjreedy changed the title IDLE/tkinter: in simpledialog, <Return> != [OK] click IDLE: replace used of tkinter simpledialog with query.Query May 30, 2017
    @terryjreedy terryjreedy changed the title IDLE: replace used of tkinter simpledialog with query.Query IDLE: replace uses of tkinter simpledialog with query.Query May 30, 2017
    @mlouielu
    Copy link
    Mannequin

    mlouielu mannequin commented May 31, 2017

    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) ?

    @mlouielu mlouielu mannequin removed the 3.7 (EOL) end of life label May 31, 2017
    @terryjreedy
    Copy link
    Member Author

    Louie, please don't revert header corrections made by a core developer.

    I see no mention of binding to press versus release in the original query issue: bpo-27380. Since the original query code is an edited version of previous code, I suspect I left the binding as it was. The current subclasses are used with ConfigDialog, where it may not make much difference. In any case, we will make changes somewhere to fix the problem: change the base class, move the binding in the subclass, or bind "def catch_return(event): return 'break'" to return release.

    Unfinished issue bpo-27621 is about refining details of Query button behavior, especially focus, in a cross-platform manner. I would like for us both to at least review the remaining issues there before doing this one.

    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label May 31, 2017
    @mlouielu
    Copy link
    Mannequin

    mlouielu mannequin commented May 31, 2017

    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.

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy terryjreedy changed the title IDLE: replace uses of tkinter simpledialog with query.Query IDLE goto should always update status bar line & column Mar 6, 2020
    @terryjreedy
    Copy link
    Member Author

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

    @terryjreedy terryjreedy changed the title IDLE goto should always update status bar line & column IDLE goto should use query.Query subclass Mar 8, 2020
    @terryjreedy
    Copy link
    Member Author

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

    @terryjreedy
    Copy link
    Member Author

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

    @miss-islington
    Copy link
    Contributor

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

    @miss-islington
    Copy link
    Contributor

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

    @terryjreedy
    Copy link
    Member Author

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

    @miss-islington
    Copy link
    Contributor

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

    @miss-islington
    Copy link
    Contributor

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

    @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
    3.7 (EOL) end of life topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants