Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
pqPythonScriptEditor Class Reference

#include <pqPythonScriptEditor.h>

Inherits QMainWindow.

Public Member Functions

 pqPythonScriptEditor (QWidget *parent=nullptr)
 
void setSaveDialogDefaultDirectory (const QString &dir)
 Sets the default save directory for the current buffer Internally, it is only used for the QFileDialog directory argument when saving or loading a file (ie the folder from which the QFileDialog is launched). More...
 
void setPythonManager (pqPythonManager *manager)
 Sets the pqPythonManager used for the macros. More...
 
void scrollToBottom ()
 Scroll the editor to the bottom of the scroll area. More...
 
void open (const QString &filename)
 Open a file inside the editor. More...
 
void load (const QString &filename)
 Open the given file into the current tab. More...
 
void updateTrace (const QString &str)
 Updates the trace tab text and creates a new one if it doesn't exists. More...
 
void stopTrace (const QString &str)
 Wraps up the trace tab. More...
 
void runCurrentTab ()
 Run the code inside the current tab. More...
 

Static Public Member Functions

static pqPythonScriptEditorgetUniqueInstance ()
 Utility function that provides a single instance of the editor. More...
 
static void updateMacroList ()
 Triggers an macro list update if the PythonManager exists. More...
 
static void updateScriptList ()
 Triggers the script list update. More...
 
static void linkTo (QTextEdit *obj)
 Link the input QTextEdit to one of the tab of the editor. More...
 
static void bringFront ()
 Opens and bring the editor in front of other windows. More...
 
static QString getMacrosDir ()
 Returns the macro directory. More...
 
static QString getScriptsDir ()
 Returns the script directory. More...
 

Protected Member Functions

void closeEvent (QCloseEvent *event) override
 Override the QMainWindow closeEvent We ask the user wants to save the current file if it's not already saved. More...
 

Detailed Description

This widget can be used as a embedded Qt python editor inside paraview. It provides functionality to read, write and edit python script and paraview macros within paraview itself. The text editor provides basic functionality such as undo/redo, line numbering and syntax highlighting (through pygments).

You can either use this widget as a sole editor, or get the paraview static one from GetUniqueInstance (which gives you the editor used for the macro and the scripts).

Note that GetUniqueInstance is a lazy way of having a unique instance of the editor ready to be used. A better approach would be to actually change the code that uses this class to reflect that peculiar behavior (and not embed it inside the class). Also note that you can freely instantiate as many editor as you want as two instances of this class don't share any common data.

Note
This class handles the main window components. If you are interested only in the text editor itself, please see pqPythonTextArea.

Definition at line 40 of file pqPythonScriptEditor.h.

Constructor & Destructor Documentation

◆ pqPythonScriptEditor()

pqPythonScriptEditor::pqPythonScriptEditor ( QWidget *  parent = nullptr)
explicit

Member Function Documentation

◆ setSaveDialogDefaultDirectory()

void pqPythonScriptEditor::setSaveDialogDefaultDirectory ( const QString &  dir)

Sets the default save directory for the current buffer Internally, it is only used for the QFileDialog directory argument when saving or loading a file (ie the folder from which the QFileDialog is launched).

◆ setPythonManager()

void pqPythonScriptEditor::setPythonManager ( pqPythonManager manager)

Sets the pqPythonManager used for the macros.

◆ scrollToBottom()

void pqPythonScriptEditor::scrollToBottom ( )

Scroll the editor to the bottom of the scroll area.

◆ open()

void pqPythonScriptEditor::open ( const QString &  filename)

Open a file inside the editor.

◆ load()

void pqPythonScriptEditor::load ( const QString &  filename)

Open the given file into the current tab.

◆ updateTrace()

void pqPythonScriptEditor::updateTrace ( const QString &  str)

Updates the trace tab text and creates a new one if it doesn't exists.

◆ stopTrace()

void pqPythonScriptEditor::stopTrace ( const QString &  str)

Wraps up the trace tab.

◆ runCurrentTab()

void pqPythonScriptEditor::runCurrentTab ( )

Run the code inside the current tab.

◆ getUniqueInstance()

static pqPythonScriptEditor* pqPythonScriptEditor::getUniqueInstance ( )
static

Utility function that provides a single instance of the editor.

◆ updateMacroList()

static void pqPythonScriptEditor::updateMacroList ( )
static

Triggers an macro list update if the PythonManager exists.

◆ updateScriptList()

static void pqPythonScriptEditor::updateScriptList ( )
static

Triggers the script list update.

◆ linkTo()

static void pqPythonScriptEditor::linkTo ( QTextEdit *  obj)
static

Link the input QTextEdit to one of the tab of the editor.

If this objects is already linked within the editor, switch to that tab otherwise creates a new one

◆ bringFront()

static void pqPythonScriptEditor::bringFront ( )
static

Opens and bring the editor in front of other windows.

◆ getMacrosDir()

static QString pqPythonScriptEditor::getMacrosDir ( )
static

Returns the macro directory.

◆ getScriptsDir()

static QString pqPythonScriptEditor::getScriptsDir ( )
static

Returns the script directory.

◆ closeEvent()

void pqPythonScriptEditor::closeEvent ( QCloseEvent *  event)
overrideprotected

Override the QMainWindow closeEvent We ask the user wants to save the current file if it's not already saved.


The documentation for this class was generated from the following file: