Clear PyCharm Run Window

前端 未结 8 1715
长发绾君心
长发绾君心 2020-11-29 07:10

Is there a way to clear the \"Run\" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the \"clear_all\" button, but without having to

8条回答
  •  被撕碎了的回忆
    2020-11-29 07:24

    I just relised that instead of going to the trouble of setting up a shortcut, you could just set up a command using PyAutoGUI to click on the trash bin on the side of the window e.g

    note, to install pyautogui click on the end of the import pyautogui line, then press alt+enter and click install pyautogui.

    import pyautogui
    
    # to find the coordinates of the bin...
    from time import sleep
    sleep(2) # hover your mouse over bin in this time
    mousepos = pyautogui.position() gets current pos of mouse
    print(mousepos) # prints current pos of mouse
    
    # then to clear it;
    pyautogui.click(x, y) # and just put this line of code wherever you want to clear it
    

    (this isn't perfect thanks to the time it takes to run the code and using the mouse, but it is reasonable solution depending on what you are using it for.) I hope this answer is helpful even though this is an old question.

提交回复
热议问题