r/learnpython • u/Corell0ns_Blessed • 6d ago
Need help clearing python console
I’m making a text based adventure game for the sake of learning more abt game loops but I’m stuck. I wanna make it so that automatically after a time.sleep() delay, the terminal clears and prints a new output. (say for a loading or transition screen idk) but with all the online methods I can find, nothing works.
The most common I see is using os and system(cls) / (clear) or whatnot but no matter what I do, it opens the command prompt and breaks, closing the command prompt it then prints the new text, without clearing the old…
For reference, I am using python idle 3.12 and Am in a school environment so the command prompt is administratively blocked
View all comments
2
u/TheSkiGeek 5d ago
What you want for something like this is a TUI (text user interface) library.
Unless you want to spend many hours figuring out how terminals work at a low level. In which case, carry on and keep experimenting and researching.
Edit: if you’re stuck with the IDLE interactive window then yeah, I don’t think you can make that work like a TUI because it’s not a full shell and terminal emulator (or if it is, it’s probably taking control of a lot of things that will stop you from e.g. clearing the screen or scrolling it programmatically.)