I want to create a text based GUI for a python game. I intend to move a character around between multiple lines of text. after hours of searching online, the solutions I found don't work for this. I want something that will erase all text on screen, so I can re-print the same line, but with the character moved one space. To be clear, the screen I want to erase is the one that appears when you hit "run module" in IDLE. Also, I cannot import any external libraries, because for some reason, that is broken on my computer.
I've tried ctrl+l. It did absolutely nothing. I've tried to use os.system('cls') (I'm on windows) It opens command prompt, clears it, then closes it. not what I need. print ("\n" * 50) works, but doesn't clear the screen. The screen MUST be clear, I don't want to print a million new lines.
Here is my code:
import sys
valone = 5
valtwo = 5
# create line of text
sys.stdout.write(" a " * valone + " t " + " a " * valtwo)
# move t character 1 space
valone = valone -1
valtwo = valtwo + 1
# clear screen and redraw line with t moved 1 space.
That is not possible with IDLE's Python shell.
From the documentation:
Shell never throws away output.
and
Tab characters cause the following text to begin after the next tab stop. (They occur every 8 ‘characters’). Newline characters cause following text to appear on a new line. Other control characters are ignored or displayed as a space, box, or something else, depending on the operating system and font.
Meaning it's a very basic shell that outputs all text in a linear fashion. You need to run Python in a different shell to accomplish what you want.