@@ -1534,28 +1534,30 @@ def main():
1534
1534
args .remove (filename )
1535
1535
if not args :
1536
1536
flist .new ()
1537
+
1537
1538
if enable_shell :
1538
1539
shell = flist .open_shell ()
1539
1540
if not shell :
1540
1541
return # couldn't open shell
1541
-
1542
1542
if macosxSupport .runningAsOSXApp () and flist .dict :
1543
1543
# On OSX: when the user has double-clicked on a file that causes
1544
1544
# IDLE to be launched the shell window will open just in front of
1545
1545
# the file she wants to see. Lower the interpreter window when
1546
1546
# there are open files.
1547
1547
shell .top .lower ()
1548
+ else :
1549
+ shell = flist .pyshell
1548
1550
1549
- shell = flist . pyshell
1550
- # handle remaining options:
1551
+ # Handle remaining options. If any of these are set, enable_shell
1552
+ # was set also, so shell must be true to reach here.
1551
1553
if debug :
1552
1554
shell .open_debugger ()
1553
1555
if startup :
1554
1556
filename = os .environ .get ("IDLESTARTUP" ) or \
1555
1557
os .environ .get ("PYTHONSTARTUP" )
1556
1558
if filename and os .path .isfile (filename ):
1557
1559
shell .interp .execfile (filename )
1558
- if shell and cmd or script :
1560
+ if cmd or script :
1559
1561
shell .interp .runcommand ("""if 1:
1560
1562
import sys as _sys
1561
1563
_sys.argv = %r
@@ -1566,13 +1568,14 @@ def main():
1566
1568
elif script :
1567
1569
shell .interp .prepend_syspath (script )
1568
1570
shell .interp .execfile (script )
1569
-
1570
- # Check for problematic OS X Tk versions and print a warning message
1571
- # in the IDLE shell window; this is less intrusive than always opening
1572
- # a separate window.
1573
- tkversionwarning = macosxSupport .tkVersionWarning (root )
1574
- if tkversionwarning :
1575
- shell .interp .runcommand ('' .join (("print('" , tkversionwarning , "')" )))
1571
+ elif shell :
1572
+ # If there is a shell window and no cmd or script in progress,
1573
+ # check for problematic OS X Tk versions and print a warning
1574
+ # message in the IDLE shell window; this is less intrusive
1575
+ # than always opening a separate window.
1576
+ tkversionwarning = macosxSupport .tkVersionWarning (root )
1577
+ if tkversionwarning :
1578
+ shell .interp .runcommand ("print('%s')" % tkversionwarning )
1576
1579
1577
1580
while flist .inversedict : # keep IDLE running while files are open.
1578
1581
root .mainloop ()
0 commit comments