This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE goto should use query.Query subclass
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: louielu, miss-islington, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2016-05-24 23:26 by terry.reedy, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18868 merged terry.reedy, 2020-03-09 05:14
PR 18869 merged miss-islington, 2020-03-09 05:38
PR 18870 merged miss-islington, 2020-03-09 05:38
PR 18871 merged terry.reedy, 2020-03-09 07:18
PR 18886 merged miss-islington, 2020-03-09 20:51
PR 18887 merged miss-islington, 2020-03-09 20:51
Messages (18)
msg266289 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-05-24 23:26
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.
msg268186 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-11 05:53
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.
msg268193 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-06-11 06:26
Okay, will take a look at the status bar code and update mechanism.
msg268197 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-11 07:59
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.
msg294547 - (view) Author: Louie Lu (louielu) * Date: 2017-05-26 12:44
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.
msg294735 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-30 04:12
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.
msg294806 - (view) Author: Louie Lu (louielu) * Date: 2017-05-31 02:54
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) ?
msg294812 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-31 05:45
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: #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 #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.
msg294814 - (view) Author: Louie Lu (louielu) * Date: 2017-05-31 06:01
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 #30422 want to do.
msg363476 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-06 02:47
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. #39844.  I may fix that and this with one PR.
msg363673 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-08 19:05
Since PR-18801 fixed the status issue, I am returning this to the box replacement issue.
msg363687 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-08 21:50
The related issue is #39852.  Since its PR-18801 fixed the status issue, I am returning this to the box replacement issue.
msg363692 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-09 05:38
New changeset e53a3932cb01683b0fa8a7448ca25a2e658c39e6 by Terry Jan Reedy in branch 'master':
bpo-27115: Move IDLE Query error blanking (GH-18868)
https://github.com/python/cpython/commit/e53a3932cb01683b0fa8a7448ca25a2e658c39e6
msg363693 - (view) Author: miss-islington (miss-islington) Date: 2020-03-09 05:54
New changeset 9d5ed8355d4cb73ab13fa6094c9ab57798dff3be by Miss Islington (bot) in branch '3.7':
bpo-27115: Move IDLE Query error blanking (GH-18868)
https://github.com/python/cpython/commit/9d5ed8355d4cb73ab13fa6094c9ab57798dff3be
msg363694 - (view) Author: miss-islington (miss-islington) Date: 2020-03-09 05:56
New changeset f3f0c7a108cd2a5071592e77e2f4b14ca35d4fcc by Miss Islington (bot) in branch '3.8':
bpo-27115: Move IDLE Query error blanking (GH-18868)
https://github.com/python/cpython/commit/f3f0c7a108cd2a5071592e77e2f4b14ca35d4fcc
msg363771 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-09 20:51
New changeset 363fab83b8a0e6d924c7a7c577feec6a2812bb8c by Terry Jan Reedy in branch 'master':
bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871)
https://github.com/python/cpython/commit/363fab83b8a0e6d924c7a7c577feec6a2812bb8c
msg363793 - (view) Author: miss-islington (miss-islington) Date: 2020-03-09 23:45
New changeset cadfe52a006abb46ea0948c6ae2e006064b4a091 by Miss Islington (bot) in branch '3.8':
bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871)
https://github.com/python/cpython/commit/cadfe52a006abb46ea0948c6ae2e006064b4a091
msg363794 - (view) Author: miss-islington (miss-islington) Date: 2020-03-09 23:45
New changeset f8345358bcdd276eb470778daf05d343da9f1290 by Miss Islington (bot) in branch '3.7':
bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871)
https://github.com/python/cpython/commit/f8345358bcdd276eb470778daf05d343da9f1290
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71302
2020-03-10 01:07:06terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-09 23:45:40miss-islingtonsetmessages: + msg363794
2020-03-09 23:45:22miss-islingtonsetmessages: + msg363793
2020-03-09 20:51:41miss-islingtonsetpull_requests: + pull_request18244
2020-03-09 20:51:34miss-islingtonsetpull_requests: + pull_request18243
2020-03-09 20:51:28terry.reedysetmessages: + msg363771
2020-03-09 07:18:55terry.reedysetstage: test needed -> patch review
pull_requests: + pull_request18229
2020-03-09 06:34:41terry.reedysetdependencies: - Finish IDLE Query dialog appearance and behavior.
stage: patch review -> test needed
2020-03-09 05:56:32miss-islingtonsetmessages: + msg363694
2020-03-09 05:54:37miss-islingtonsetmessages: + msg363693
2020-03-09 05:38:28miss-islingtonsetpull_requests: + pull_request18228
2020-03-09 05:38:22miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request18227
2020-03-09 05:38:13terry.reedysetmessages: + msg363692
2020-03-09 05:14:47terry.reedysetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request18226
2020-03-08 21:50:38terry.reedysetmessages: + msg363687
2020-03-08 19:05:13terry.reedysetmessages: + msg363673
title: IDLE goto should always update status bar line & column -> IDLE goto should use query.Query subclass
2020-03-06 02:47:51terry.reedysetmessages: + msg363476
title: IDLE: replace uses of tkinter simpledialog with query.Query -> IDLE goto should always update status bar line & column
2017-05-31 06:01:43louielusetmessages: + msg294814
2017-05-31 05:45:16terry.reedysetdependencies: + Finish IDLE Query dialog appearance and behavior.
messages: + msg294812
versions: + Python 3.7, - Python 3.5
2017-05-31 02:54:04louielusetmessages: + msg294806
versions: + Python 3.5, - Python 3.7
2017-05-30 04:14:35terry.reedysettitle: IDLE: replace used of tkinter simpledialog with query.Query -> IDLE: replace uses of tkinter simpledialog with query.Query
2017-05-30 04:12:58terry.reedysettitle: IDLE/tkinter: in simpledialog, <Return> != [OK] click -> IDLE: replace used of tkinter simpledialog with query.Query
messages: + msg294735
versions: + Python 3.7, - Python 3.5
2017-05-26 12:44:15louielusetnosy: + louielu
messages: + msg294547
2016-06-11 07:59:05serhiy.storchakasetmessages: + msg268197
2016-06-11 06:26:14terry.reedysetassignee: terry.reedy
messages: + msg268193
2016-06-11 05:53:04serhiy.storchakasetmessages: + msg268186
components: - Tkinter
2016-05-24 23:26:29terry.reedycreate