Title: IDLE - standardize dialogs
Type: enhancement Stage: test needed
Components: IDLE Versions: Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: markroseman, taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2008-02-09 00:10 by taleinat, last changed 2018-06-13 04:47 by terry.reedy.

File name Uploaded Description Edit
IDLE_standardize_dialogs.081129.patch taleinat, 2008-11-29 18:26 updated patch review
IDLE_standardize_dialogs_2.7_2013-05-24.patch ned.deily, 2013-05-24 21:00 Tal's patch updated for current 2.7 tip
Messages (21)
msg62214 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2008-02-09 00:10
In many places in the code, tkMessageBox dialogs were being used
directly, with the master (parent) widget being set explicitly to the
EditorWindow's text widget. Only in some cases was the focus being set
to the text widget afterwards, although in most this is the Right Thing
To Do.

This patch adds a decorator which wraps a tkMessage box (or similar)
function to use the EditorWindow's text widget as a parent by default
and set focus back to it afterwards. This is used to wrap the showerror
and ask* methods. It also changes the code to use these methods wherever

All in all, the change in functionality is that the dialogs' parent
widget will always be the text widget, and that focus will always be
returned to it. This makes the interface more consistent. As a bonus, a
lot of repetitive cruft is removed from the code, and writing extensions
is made another bit simpler.
msg62216 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2008-02-09 01:54
Bah, the initial version contained a silly bug in
EditorWindow.goto_line_event. Please remove it, and use this version
msg62219 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2008-02-09 11:20
Going through the code more thoroughly, found additional places where
the standardized dialogs should be used. Also fixed remaining places
where these dialogs are used but the parent widget was still being
explicitly set to be the text widget, which is now the default.

(should be easy to apply both patches in any order without conflicts)
msg62270 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2008-02-11 02:42
I would greatly appreciate it if you would slow down and test your 
patches and use them for an extended period of time (preferably with 
some other people trying them) before submitting them.  It's quite 
aggravating to start working on one, and even have it checked in, only 
to have to start over again.  It doubles the work and makes me 
unwilling to address your patches.  How much time have you given the 
second version?  Deleting both patches, please provide a combination 
after you've tested it and thought about it for a few days.
msg65885 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2008-04-27 15:00
Please provide a single patch file.
msg65977 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2008-04-29 18:23
uploaded a single comprehensive patch file
msg67848 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2008-06-08 21:13
After more testing, I discovered a bug which broke Goto Line. Attaching
a fixed patch.
msg76619 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2008-11-29 18:26
Attaching a new patch against a more recent revision (resolved minor

Only 3 extremely minor changes from previous patch: fixed two more
places where the parent was being passed explicitly (no longer required)
and changed two tabs -> spaces.

I've done some fairly thorough manual testing of this, and have been
using it without any issues for almost six months.
msg91183 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-08-02 15:11
I have reviewed the latest patch now, it is nice in general but I
dislike the idea of increasing even more EditorWindow. I would really
prefer to put this somewhere else, like.. idlelib/ Also, I'm
inclined to remove this master/parent hiding and continue making it
msg91197 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2009-08-02 19:22
The whole point of this patch is to make the EditorWindow's Text widget
the default master/parent for its dialogs!

IMO this makes sense, since this is a reasonable and intuitive default
for such methods of the EditorWindow object. I understand the "explicit
is better than implicit" argument, but that doesn't mean that having a
reasonable default value is always wrong. In this case having a default
value both simplifies the code considerably and makes sense, so IMO it
is justified.

Also, please note that the patch actually reduces the size of (both character and line counts) and cleans up the code
in many places. Yes, the definition of the relevant methods is not
trivial, but it is in just one area of the code.
msg91206 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-08-02 20:54
I thought the main point of this issue was to define standard functions,
methods, classes (or something in that sense), in order to make the
creation of tk dialogs uniform across IDLE.

Right now it seems reasonable to keep the parent hidden, but I think it
may not help much for maintaining. I really consider a good idea to
define explicitly who is the parent of a dialog, it wasn't an attempt to
refer to the phrase you cited.

I trust you it reduces the size on that file, I really didn't count how
many lines were removed and how many were added, but these dialogs can
be used anywhere around IDLE so I don't see why keeping them inside
EditorWindow is a good idea. It would reduce even more (some few lines)
EditorWindow's size doing so, and it would make more sense as I see.
msg109873 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2010-07-10 14:41
Because of the method of implementation, a dialog can be created without specifying a parent. There was at least one instance of this in IDLE before my patch. This is a bug, since the behavior of the dialog in this instance is obviously incorrect (the user can switch focus back to the parent while the dialog is still open).

I found that making the EditorWindow the default parent was the best way to both fix the bug, make the code more readable, and avoid replicating this bug in the future. Feel free to write up a different patch or change mine if you feel so strongly about the default parent.

The process of discussing this patch has taken far, far too long. I can't stand such discussions spanning months (and years!). Please just accept this patch or close it. I'm fed up with this.
msg109913 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2010-07-10 19:32
> Tal Einat added the comment:
> ...
> The process of discussing this patch has taken far, far too long. I can't stand such discussions spanning months (and years!). Please just accept this patch or close it. I'm fed up with this.

If the patch were good enough for everyone then it could have been
committed about 2 years ago, but it is not the case apparently (kbk
also raised some points earlier). Also, the effective discussion has
taken maybe some hours and this large extra time shows this issue is
not important enough to be noticed and taken proper care (and I'm
mostly sure you know this situation isn't exclusive to this
issue/Python/other (closed or open) projects). Said that, I don't see
the reason to just accept the patch and close the issue if no one else
fully backs up your patch.

I understand you may want to no longer follow the issue, and I can't
blame you because I've been mostly away from Python development these
msg109942 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2010-07-10 23:06
At this point I would prefer that this patch just be rejected rather than continue discussing it.

I can understand IDLE being a low priority, but someone could have just stated that to begin with and I wouldn't have bothered working for hours to work up a patch and discuss its merits.

Guilherme, I appreciate your taking an interest in this and obviously you have only helped move this forward. My frustration is with the devs allowing me to waste hours of my time, while requesting that I spend even more time testing and consolidating patches before submission, and then proceeding to ignore my work completely.
msg110628 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-18 10:28
For the record there has been a sizeable thread on python-dev in the last few days regarding IDLE.  As a result it is extremely likely that IDLE outstanding issues will be picked up, so please leave this issue open.
msg189913 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-05-24 16:04
Bump as IDLE is now being actively developed.
msg189925 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-05-24 19:18
I have not looked at the details, so cannot currently comment as to whether the idea should be pursued or dropped. Perhaps when Roger is done with overt bugs he will take a look and offer an opinion.
msg189931 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-05-24 21:00
Attached is a refreshed version of the patch against current 2.7 tip.  I did a quick visual comparison with the original but make no guarantees that it is totally accurate.  I have no plans to work on it further myself.
msg190513 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-06-03 02:33
The patch does two things.

1. It replaces the existing direct rebinding of messagebox functions as methods, such as
    self.showerror = tkMessageBox.showerror
with binding of a double wrapping of the functions. The middle layer is useless and only serves to allow use of the decorator syntax. The 'old-fashioned' method of wrapping by function call should be used.
    self.showerror = _tk_dialog_wrapper(tkMessageBox.showerror)
A single customized wrapping for the existing bindings seems like it might be a good idea.

I do not understand the 'motivation' (of the existing and revised method bindings) of making Idle extensions 'cross-IDE'. How so? What IDEs other than Idle are we concerned with?

The patch replaces both parent=self.text and master=self.text in current calls with parent=self.text in the wrapper. This seems to assume that parent==master in these contexts. I gather that this is nearly always the case.
based on Grayson's book) But I wonder if the choice could ever make a difference.

2. Currently, EditorWindow methods sometimes call a message function as a message module attribute and sometimes as one of the EditorWindow method. The patch makes these calls consistently be methods calls (to the wrappers). It also changes call in classes that are EditorWindow subclasses or containers. (askokcancel is addded to EditorWindow for patches to some of these other classes.)

My current Idle concern is testing. The current inconsistency in EditorWindow is not good for that, so I will want to fix that one way or the other in any case. For automated non-gui testing, the message functions (or the message module) need to be replaced with mocks that a) save the args somewhere where they can be later retrieved and b) return without graphics system and user interaction. For modules with non-editor classes, this means monkey-patching the module. (I have done this once for one test.) I will experiment with also monkey-patching editor windows.
msg319292 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-06-11 11:03
I suggest that we close this issue. IMO the potential benefit is too small relative to the work required, and the interest is too low.
msg319424 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-06-13 04:47
I would rather leave this open for the moment as an information resource.  I wrote with a base class and subclasses to standardize asking users for input.  So some of the patch may be obsolete, but it does have a catalog of popup uses.

The patch consistently replaces tkMessagebox.showerror with widget.showerror.  I have done that in several places, although widget.showerror may just be messagebox.showerror.  At least some of my motivation was making testing easier, by adding a mock to the test instance instead of temporarily monkeypatching messagebox.  If a custom Showerror class were defined in, for instant,, "self.showerror = tkMessagebox.showerror" could easily be replaced by "self.showerror = query.Showerror.

I also have some interest in consistently handling focus in response to key presses.  (There was recently a request for this on idle-dev.)
Date User Action Args
2018-06-13 04:47:24terry.reedysetnosy: - kbk, gpolo, ned.deily, roger.serwy, Todd.Rovito

messages: + msg319424
stage: patch review -> test needed
2018-06-11 11:03:18taleinatsetmessages: + msg319292
2017-06-30 00:37:18terry.reedysetassignee: terry.reedy
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.3, Python 3.4
2015-08-12 15:49:49markrosemansetnosy: + markroseman
2014-02-03 17:08:20BreamoreBoysetnosy: - BreamoreBoy
2013-06-03 02:33:03terry.reedysetmessages: + msg190513
2013-05-27 04:02:28Todd.Rovitosetnosy: + Todd.Rovito
2013-05-24 21:00:25ned.deilysetfiles: + IDLE_standardize_dialogs_2.7_2013-05-24.patch
nosy: + ned.deily
messages: + msg189931

2013-05-24 19:18:41terry.reedysetversions: + Python 2.7, Python 3.3, Python 3.4, - Python 3.2
nosy: + roger.serwy

messages: + msg189925

assignee: kbk -> (no value)
2013-05-24 16:04:49BreamoreBoysetmessages: + msg189913
2010-07-18 17:51:29terry.reedysetfiles: - IDLE_standardize_dialogs.080609.patch
2010-07-18 17:51:02terry.reedysetfiles: - IDLE_standardize_dialogs.080429.patch
2010-07-18 10:28:37BreamoreBoysetnosy: + terry.reedy, BreamoreBoy
messages: + msg110628
2010-07-10 23:06:52taleinatsetmessages: + msg109942
2010-07-10 19:32:45gpolosetmessages: + msg109913
2010-07-10 14:41:38taleinatsetmessages: + msg109873
2010-07-10 06:38:47terry.reedysetversions: + Python 3.2, - Python 2.6
2009-08-02 20:54:09gpolosetmessages: + msg91206
2009-08-02 19:22:18taleinatsetmessages: + msg91197
2009-08-02 15:11:27gpolosetmessages: + msg91183
2009-04-26 22:15:47ajaksu2setnosy: + gpolo

stage: patch review
2008-11-29 18:26:58taleinatsetfiles: + IDLE_standardize_dialogs.081129.patch
messages: + msg76619
2008-06-08 22:08:44taleinatsetfiles: + IDLE_standardize_dialogs.080609.patch
2008-06-08 22:07:37taleinatsetfiles: - IDLE_standardize_dialogs.080609.patch
2008-06-08 21:13:43taleinatsetfiles: + IDLE_standardize_dialogs.080609.patch
messages: + msg67848
2008-04-29 18:23:15taleinatsetfiles: + IDLE_standardize_dialogs.080429.patch
messages: + msg65977
2008-04-27 15:00:44kbksetmessages: + msg65885
2008-02-11 02:42:44kbksetfiles: - IDLE_standardize_dialogs.080209_2.patch
2008-02-11 02:42:39kbksetfiles: - IDLE_standardize_dialogs.080209.patch
2008-02-11 02:42:30kbksetmessages: + msg62270
2008-02-09 11:20:34taleinatsetfiles: + IDLE_standardize_dialogs.080209_2.patch
messages: + msg62219
2008-02-09 02:17:49christian.heimessetfiles: - IDLE_standardize_dialogs.080208.patch
2008-02-09 02:17:43christian.heimessetpriority: normal
assignee: kbk
type: enhancement
keywords: + patch
versions: - Python 2.5
2008-02-09 01:54:42taleinatsetfiles: + IDLE_standardize_dialogs.080209.patch
messages: + msg62216
2008-02-09 00:10:20taleinatcreate