classification
Title: IDLE: only allow single instance
Type: Stage: resolved
Components: IDLE Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: epaine, taleinat, terry.reedy
Priority: normal Keywords:

Created on 2020-06-17 09:22 by epaine, last changed 2020-07-28 01:09 by terry.reedy. This issue is now closed.

Messages (6)
msg371722 - (view) Author: E. Paine (epaine) * Date: 2020-06-17 09:22
I propose that IDLE only allows a single instance, but behaves mostly like before (multiple shells, etc.). The main motivation for this issue is to (1) stop the same file being opened more than once and (2) make a tabbed interface easier to implement.

Starting with point (1), believe a file should not be allowed to be opened multiple times but enforcing this currently in IDLE would be incredibly difficult.

Instead, I propose that a socket-server sits on the main instance and any new instances send requests to the main instance (to open a file in a new 'instance'). There would be two layers of file-lists, and the current one still acts as an 'instance' file-list but we also create a master list which controls all of the 'instances':

Instance flist      Instance flist
     |                   |
     ---- Master flist ----

Secondly, point (2). I am currently in the planning phase of creating an IDLE tabbed interface (based loosely off the code currently found in #9262) but it requires both this issue and #40893 to be pulled before it can work effectively (dragging tabs between windows, etc.).

I don't currently have any code to propose, but I don't think it should be *too* difficult to implement (but now I've said that!...).
msg371729 - (view) Author: E. Paine (epaine) * Date: 2020-06-17 10:45
Sorry, I feel I need to clarify. When I say "... requires ... #40893 to be pulled ..." I mean that that would be the preferred way to transfer tabs. If TkDND is not available, or the version is a backport (which wouldn't have the bindings) then tab transfer will use Toplevels instead. The preferred method would be TkDND, but any change should not require it to provide full functionality.
msg371749 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-06-17 15:10
I am somewhat dubious about this.  IDLE *must* allow side-by-side windows.  AFAIK, single instance Notepad++ does not allow this.  Tiles rather than only tabbed windows can potentially be done with with one process (turtledemo), but we are not there yet.  I have no idea how easy it is to enforce 'one process' across platforms.
msg371769 - (view) Author: E. Paine (epaine) * Date: 2020-06-17 18:39
I appreciate your concerns Terry and I guess I must start by saying as much as I like notepad++, I don't like how their instances work. This issue shouldn't change any behaviour (from a user's perspective) other than not being able to open the same file twice.

The idea is that each group (what we pretend is an instance) will be almost completely self-contained. Each instance will have its own shell (they will not share, etc.) and the windowed design will remain (for now...).

What they will share is the main tkinter root (Tk instance) and the bottom layer of a stack-like file-list system (which I failed to properly describe in the original message). Calls will only descend the stack as far as necessary, but it allows one group to bring another group's editor to the front when the file tries to open a second time (like how an instance can raise any of its editors).

The finer details are yet to be confirmed as I don't have any code, but it is likely that settings will take effect immediately across all groups and I have yet to decide whether the 'window' menu should be unified of per-group.

I understand that the immediate benefits of this issue are not worth the change required, however I believe it would be highly beneficial going forward for groups to be able to communicate (like my previous example of creating a tabbed interface).
msg374418 - (view) Author: E. Paine (epaine) * Date: 2020-07-27 20:01
Is it worth me developing a PR for this issue, as it may be a suitable fix for #38946? (I am not guaranteeing any code, though, but I will try). If not, I will probably close this issue.
msg374448 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-07-28 01:09
We cannot prevent files being viewed and possibly modified by multiple programs and in general, should not.  I often open a file in more than one python version.  In any case, the proposed change would have a high chance on introducing bugs.  I just finished (I hope) repairing regressions in 3.8.4.  And 

There are, however, two real issues.  One is being able to reload a file, either because it has been changed on disk or because one want to abandon edits since the last save.  The other is detecting when a file might need to be reloaded because of external changes.

Reloading is the subject of #1721083 (from 2007).  I just outlined a easy fix there. The hard part is adding tests for the affected method.  You can do that if you want, and say so before I do it.

Detecting file changes like Notepad++ does would be a different issue.

#38946 is about Catalina making incompatible changes in Apple graphics so that tcl/tk does not work as well as it does in Mohave.

To me, the main blocker for multiple tabs is separating editor frames with a text widget from editor windows with a menu.  And the need to refactor the hierarchy of text frames.  And to stop duplicating per class objects as per instance objects.
History
Date User Action Args
2020-07-28 01:09:43terry.reedysetstatus: open -> closed
resolution: rejected
messages: + msg374448

stage: resolved
2020-07-27 20:01:37epainesetmessages: + msg374418
2020-06-17 18:39:38epainesetmessages: + msg371769
title: IDLE only allow single instance -> IDLE: only allow single instance
2020-06-17 15:10:18terry.reedysetmessages: + msg371749
versions: - Python 3.7
2020-06-17 10:45:55epainesetmessages: + msg371729
2020-06-17 09:22:18epainecreate