Clear PyCharm Launch Window

Is there a way to clear the Run console in PyCharm? I want a code that removes / hides all previously executed print (). Like the "clear_all" button, but without the need to manually manually.

I read that there is a way to do this in the terminal with os.system ("cls"), but in PyCharm it adds only a small square without clearing anything.

Also, I don't want to use print ("\ n" * 100), because I don't want you to be able to scroll back and see previous prints.

+7
pycharm
source share
2 answers

In Pycharm:

  • CMD + , (or Picharma preferences );
  • Search: "clear all";
  • Double click → Add keyboard shortcut (set it to CTRL + L or something else)
  • Enjoy this new hotkey in your Pycharm console!
+6
source share

This question is a little old, but I thought I would leave it here for other people who are wondering how to do this.

how

  • Download this package https://github.com/asweigart/pyautogui . This allows the python to send key touches.

    You may need to install some other packages first.

    If you install PyAutoGUI from PyPI using pip:

    There are no dependencies on Windows. Win32 extensions do not have to be installed.

    OS X needs to install the pyobjc-core and pyobjc module (in that order).

    Linux needs the python3-xlib module (or python-xlib for Python 2) installed. The pillow needs to be installed, and on Linux you may need to install additional libraries to make sure Pillow PNG / JPEG is working properly. Cm:

  • Set a keyboard shortcut to clear the launch window in pycharm, as Taylan Aydinli explains

    • CMD +, (or Picharma preferences);

    • Search: "clear all"; Double click →

    • Add a keyboard shortcut (set it to CTRL + L or something else)

    • Enjoy this new hotkey in your Pycharm console!

  • Then, if you set the keyboard shortcut to "clear everything" to Command + L , use this in your python script

     import pyautogui pyautogui.hotkey('command', 'l') 

Program example

This will clear the screen after user input.

EDIT: If you do not focus on the tool window, your clear hotkey will not work, you can see for yourself if you try to press the hotkey when you focus on, say, an editor, you will not clear the contents of the built-in terminals.

PyAutoGUI does not have the ability to directly focus on windows to solve this problem, you can try to find the coordinate where the launch terminal is located, and then left-click to focus, if you do not know the coordinates where you can click the mouse, you can find it with the following code:

 import pyautogui from time import sleep sleep(2) print(pyautogui.position()) 

Output Example:

 (2799, 575) 

and now the actual code:

 import pyautogui while True: input_1 = input("?") print(input_1) pyautogui.click(x=2799, y=575) pyautogui.hotkey('command', 'l') 
+2
source share

All Articles