[issue39325] Original window focus when opening IDLE by double clicking Python file Mac

Terry J. Reedy report at bugs.python.org
Fri Mar 27 14:53:19 EDT 2020


Terry J. Reedy <tjreedy at udel.edu> added the comment:

Ned, I believe that this issue results from peculiarities of how macOS runs apps.  Insight from you would be appreciated.

macOS Sierra 10.2.8?, Python 3.7.3 (Did you use python.org installer?)

On my Win10, multiple IDLE windows are cascaded to the right and down.  Each window opened gets the focus until the focus is moved.  So on startup, the last window opened ends up with the focus.
  'python -m idlelib tem tem2' opens tem and then tem2.
  'python -m idlelib -i tem' opens tem then a shell.

The order is set in pyshell.main(), where sys.args is parsed to set boolean enable_edit and enable_shell.  Then 'if enable_edit: ...' and 'if enable_shell: ...' execute.  I presume that the logic is that if one wants to immediately edit and run an existing file, there is little reason pass args to cause a shell opened also.

I watched your video a couple of times.  It appears to show Shell being opened first (with the focus) and then an editor being opened on top of it, but without getting the focus.  AFAIK, both are impossible.

One possible interpretation: editor and shell are opened in the normal order, with the editor somehow not appearing.  Then macOS intervenes to lift the editor above the shell, but without shifting the focus.  Or macOS intervenes some other way.  Or the specific tk in use on macOS has some undocumented macOS-specific behavior.  (The tcl/tk folk claim that 8.6.10 follows the doc better.)  In all these cases, IDLE's code is not responsible.  If you want to chase down the details, add some logging to pyshell.main.

The root problem is asking IDLE to open a shell.  For me, 'python -m idlelib tem' only opens tem without a shell.  Ditto for right-click 'Edit with IDLE'.  Can you tell what command is used to start IDLE with double clicks?  Can you change it to not open Shell?  Also, does updating to 3.7.7 (recommended) change anything?

I am inclined to close this as a 3rd party or non-bug issue, but will wait a bit for Ned to comment.

----------
nosy: +ned.deily

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39325>
_______________________________________


More information about the Python-bugs-list mailing list