This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE: Move prompts with input.
Type: behavior Stage: test needed
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: louielu, terry.reedy
Priority: normal Keywords:

Created on 2017-09-02 23:52 by terry.reedy, last changed 2022-04-11 14:58 by admin.

Messages (4)
msg301177 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-02 23:52
When this program (from thread by Steven D'Aprano) on python-list is run

import time
from threading import Timer

def do_work():
    x = 2 + 2
    print("It is", time.asctime(), "and 2+2 is", x)

def go():
    Timer(10, do_work, ()).start()  # schedule it in one minute

The response, if it occurs while one in entering a statement, 'pushes down' the entry in progress.

======================= RESTART: F:\Python\mypy\tem.py =======================
>>> go()
>>> It is Sat Sep  2 19:42:10 2017 and 2+2 is 4  #<== output
a = (
	12,   # <== 2nd line of entry in progress

The prompt should be pushed down too.
msg301217 - (view) Author: Louie Lu (louielu) * Date: 2017-09-04 12:42
minimum reproduce:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
>>> 'hello'
a = (
       12,

-------------------

And the expect output should be something like:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
>>> 'hello'    # No <enter> or other key-input
>>>

or:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
'hello'
>>>

Right?
msg301218 - (view) Author: Louie Lu (louielu) * Date: 2017-09-04 12:42
Or the output should be:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
>>>
'hello'
>>>
msg301242 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-04 19:10
In my example the screen before the output had

>>> go()
>>> a = 
           12,|

where '|' is the blinking input cursor.  The '\n' terminated print output is inserted *after* '>>> ' but before the imcomplete statement.  When the statement  I want it *before* the prompt, with '\n' appended if necessary.  In the minimized example, the result would be

 >>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
'hello'
>>>

If delayed output 'junk' does not end with '\n', we can get

>>> junkg=4  # 'g' started where the 'j' ends up.
>>> g
4

This is buggy as a history listing.

IDLE's current behavior, which keeps user input and program output better separated, is much better than interactive Python in the console Steven used, where the output is placed at the end of the incomplete statement, which is a nuisance.

The first step is to find where text from the user program is inserted into the Shell text box.  Then, how is the insertion point moved back -- but just not quite far enough. The solution might then be obvious.

A 'deeper' idea that would solve this (and other issues) is a separate Shell input box (without '>>> ') under the Shell history box.  But that is a separate discussion.
History
Date User Action Args
2022-04-11 14:58:51adminsetgithub: 75512
2017-09-04 19:10:37terry.reedysetmessages: + msg301242
2017-09-04 12:42:49louielusetmessages: + msg301218
2017-09-04 12:42:09louielusetnosy: + louielu
messages: + msg301217
2017-09-02 23:52:22terry.reedycreate