Author terry.reedy
Recipients IrvKalb, ned.deily, ronaldoussoren, terry.reedy
Date 2020-06-05.02:37:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591324637.45.0.879587955322.issue39325@roundup.psfhosted.org>
In-reply-to
Content
Irv also posted to idledev, where he explained his particular need: He teaches a class with assignment to write a .py file with certain behavior.  Submissions are in 1 directory.  He would like to double-click to load a file and F5 to run it.  Currently, he has to move the mouse and click the loaded editor before running and move it back.

In reply to my post yesterday, he explained how to make double-click in finder open in IDLE: """I did change the default for how my Mac opens ".py" files.  To do that I selected any ".py" and did a Get Info on it.  A tall window opens, and allows me to change the default application for opening the file.  I selected IDLE.app and chose "Change all"."""

More testing with my Macbook: both 'python3.9 -m idlelib -i file.py' in terminal *and* double-clicking in Finder open an editor, with 'Format' in the IDLE menu, open Shell (shifted right), with 'Shell' in the IDLE menu, and then lift the editor window, without giving it focus and changing the IDLE menu back.  Rereview of the video (which omits the IDLE menu) suggests the same because Shell is to the right of the editor.  The video is not as clear because the IDLE menu is omitted, the  editor has only one line, and Irv's machine is much faster.

I consider the inconsistency to be a bug.  The cause is this code after the creation of Shell.

        if macosx.isAquaTk() and flist.dict:
            # On OSX: when the user has double-clicked on a file that causes
            # IDLE to be launched the shell window will open just in front of
            # the file she wants to see. Lower the interpreter window when
            # there are open files.
            shell.top.lower()

Widgit.raise() and .lower() do not change focus.  Since there is no way to shed focus, we need to save the focus window, if there is one (and make sure it is not the withdrawn root), before creating Shell and restore it after.  There might be situations in which Shell should be left on top with the focus.
History
Date User Action Args
2020-06-05 02:37:17terry.reedysetrecipients: + terry.reedy, ronaldoussoren, ned.deily, IrvKalb
2020-06-05 02:37:17terry.reedysetmessageid: <1591324637.45.0.879587955322.issue39325@roundup.psfhosted.org>
2020-06-05 02:37:17terry.reedylinkissue39325 messages
2020-06-05 02:37:16terry.reedycreate