-
Is there a way to clear the input/output window via code? I would like to clear the window whenever I start my program. Currently the window keeps the previous outputs and I have to manually clear the input/output window. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Try https://unix.stackexchange.com/questions/124762/how-does-clear-command-work |
Beta Was this translation helpful? Give feedback.
-
On beta.pybricks.com the esc H esc 3J moves the cursor to the top, but the data remains on screen.
Ran the following to test and to me it seems that esc H esc 2J does what you want: from pybricks.tools import wait
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
wait(1000)
print("\x1b[H\x1b[3J", end="")
print("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy")
wait(1000)
print("\x1b[H\x1b[3J", end="")
print("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")
wait(1000)
print("\x1b[H\x1b[1J", end="")
print("Done esc 1J")
wait(1000)
print("\x1b[H\x1b[3J", end="")
print("Done esc 3J")
wait(1000)
print("\x1b[H\x1b[2J", end="")
wait(1000)
print("After esc 2J - Do once more to get an empty output screen")
wait(1000)
print("\x1b[H\x1b[2J", end="") Ran this on code.python.com on firmware:
Same result. [EDIT] On windows 11 with Google Chrome Version 113.0.5672.93 (Official Build) (64-bit) |
Beta Was this translation helpful? Give feedback.
Try
print("\x1b[H\x1b[2J", end="")
. These are terminal escape codes to clear the terminal.https://unix.stackexchange.com/questions/124762/how-does-clear-command-work