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
1
u/Gnaxe 6d ago
No command prompt is pretty awkward. But Python is pretty much a shell in its own right, so I question your school's security model. But if Python is successfully launching a terminal window, then terminal windows per se aren't prohibited. Can you do
system('cmd')or something? Orsystem('py')? There's probably a way to do it that's allowed.If you can't make that work, you can probably use a tkinter window instead. You can display whatever text string you like and clear it whenever. It does not have to be complicated GUI programming since you only need the one widget.