classification
Title: IDLE: replace uses of tkinter simpledialog with query.Query
Type: behavior Stage: test needed
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: 27621 Superseder:
Assigned To: terry.reedy Nosy List: louielu, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2016-05-24 23:26 by terry.reedy, last changed 2017-05-31 06:01 by louielu.

Messages (9)
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.
History
Date User Action Args
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