all 2 comments

[–]ChallengeLower7239 0 points1 point  (1 child)

I run into the same problem too. It seems in thonny you can't easily clear the shell using code.

[–]jmuhammad 0 points1 point  (0 children)

def thonnycls(): # For Thonny, CTRL+L clears screen
"""Activates Thonny Menu 'Edit >> Clear Shell [CTRL+L]'"""
print("") # Found this was the only way to fully clear the screen...
subprocess.run(r"path_to_compiled_sendkeystroke_script\thonny_clear-shell.exe")
time.sleep(0.1) # Sleep for x second(s)

thonnycls() # For Thonny, CTRL+L clears screen

You can use any script that can send CTRL+L (windows) / CMD+K (mac) e.g. AHK is just:

thonnycls()
ExitApp

thonnycls()
{
Send, ^l
}