How can I clear Python Interactor?

Hi,

I’m using 3D-Slicer v4.10.1 and I’m wondering how can I clear Python Interactor?

Thanks

For me it works to use the right-click context menu and select all then delete.

4 Likes

Thanks Steve. It worked.

1 Like

is there a python function to do the “clearing” here?
Thanks

just found solution from @jcfr

You could use the function ctkPythonConsole::clear()

From python, the following can be done:

slicer.app.pythonConsole().clear()

From a C++ loadable module, you would have to do something like this:

#include "qSlicerApplication.h"

// CTK includes
#include <ctkPythonConsole.h>

[...]

qSlicerApplication* app = qSlicerApplication::application();
app->pythonConsole()->clear();

You could use:

>>> slicer.util.pythonShell().reset()
1 Like

Thanks a lot for the quick response. That works well.