ParaView
pqPythonShell.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqPythonShell.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 =========================================================================*/
32 #ifndef _pqPythonShell_h
33 #define _pqPythonShell_h
34 
35 #include "pqPythonModule.h" // needed for PQPYTHON_EXPORT.
36 #include "pqTimer.h"
37 #include <QWidget>
38 
39 class vtkObject;
40 class pqConsoleWidget;
41 class vtkPythonInteractiveInterpreter;
42 
53 class PQPYTHON_EXPORT pqPythonShell : public QWidget
54 {
55  Q_OBJECT
56  typedef QWidget Superclass;
57 
58 public:
59  pqPythonShell(QWidget* parent = 0, Qt::WindowFlags flags = 0);
60  ~pqPythonShell();
61 
67  void* consoleLocals();
68 
69  enum PrintMode
70  {
73  ERROR
74  };
75 
76 public slots:
80  void printMessage(const QString&);
81 
86  void clear();
87 
92  void executeScript(const QString&);
93 
98  void reset();
99 
103  bool isExecuting() const { return this->Executing; }
104 
110  void printString(const QString&, PrintMode mode = STATUS);
111 
119  static void setPreamble(const QStringList& statements);
120 
121 signals:
127  void executing(bool starting);
128 
129 protected slots:
130  void pushScript(const QString&);
131  void setExecuting(bool val) { this->Executing = val; }
132 
133 protected:
135  vtkPythonInteractiveInterpreter* Interpreter;
136  const char* Prompt;
137  static QStringList Preamble;
138 
139  static const char* PS1() { return ">>> "; }
140  static const char* PS2() { return "... "; }
141 
146  void setupInterpreter();
147  friend class pqPythonManager;
148 
153  bool prompt(const QString& indent = QString());
154 
155  void HandleInterpreterEvents(vtkObject* caller, unsigned long eventid, void* calldata);
156 
157 private:
158  Q_DISABLE_COPY(pqPythonShell)
159 
160  bool Prompted;
161  bool Executing;
162 };
163 
164 #endif // !_pqPythonShell_h
pqPythonShell is a QWidget subclass that provides an interactive Python shell.
Definition: pqPythonShell.h:53
void setExecuting(bool val)
bool isExecuting() const
Returns true is the shell is currently executing a script/command.
const char * Prompt
static const char * PS2()
Qt widget that provides an interactive console - you can send text to the console by calling printStr...
static const char * PS1()
pqPythonManager is a class to facilitate the use of a python interpreter by various paraview GUI comp...
vtkPythonInteractiveInterpreter * Interpreter
pqConsoleWidget * ConsoleWidget
static QStringList Preamble