clear console and clear report by python

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

clear console and clear report by python

Post by bernd »

Is there a possobility to clear the python console and/or report view by python?
Last edited by bernd on Fri Feb 20, 2015 6:33 pm, edited 1 time in total.
wmayer
Founder
Posts: 20298
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: clear console and clear report by pyhton

Post by wmayer »

Code: Select all

from PySide import QtGui
mw=Gui.getMainWindow()

c=mw.findChild(QtGui.QPlainTextEdit, "Python console")
c.clear()

r=mw.findChild(QtGui.QTextEdit, "Report view")
r.clear()
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: clear console and clear report by python

Post by bernd »

Thanks Werner! :)
User avatar
FredCailloux
Posts: 52
Joined: Wed Jul 14, 2021 7:37 pm
Location: Canada

Re: clear console and clear report by python

Post by FredCailloux »

I'm a beginner with FreeCAD and Python.
Since there doesn't seem to be an existing simple command to clear the Python console screen, like "cls" or "clear"
Is there a way to program a CTRL-mykey such that it will execute these code lines ?

Code: Select all

c=mw.findChild(QtGui.QPlainTextEdit, "Python console")
c.clear()
Can such CTRL-mykey be saved permanently such that it remain available in the Python console at FreeCAD startup ?
Great results only comes with great understanding. Great memory is just an illusion.
User avatar
Roy_043
Veteran
Posts: 8538
Joined: Thu Dec 27, 2018 12:28 pm

Re: clear console and clear report by python

Post by Roy_043 »

The Python console has a (right-click) context menu with a "Clear" option.
Post Reply