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 
51 class PQPYTHON_EXPORT pqPythonShell : public QWidget
52 {
53  Q_OBJECT
54  typedef QWidget Superclass;
55 public:
56  pqPythonShell(QWidget* parent=0, Qt::WindowFlags flags=0);
57  ~pqPythonShell();
58 
62  void* consoleLocals();
63 
64  enum PrintMode
65  {
68  ERROR
69  };
70 
71 public slots:
73  void printMessage(const QString&);
74 
77  void clear();
78 
81  void executeScript(const QString&);
82 
85  void reset();
86 
88  bool isExecuting() const
89  { return this->Executing; }
90 
94  void printString(const QString&, PrintMode mode=STATUS);
95 
101  static void setPreamble(const QStringList& statements);
102 
103 signals:
107  void executing(bool starting);
108 
109 protected slots:
110  void pushScript(const QString&);
111  void setExecuting(bool val) { this->Executing = val; }
112 
113 protected:
115  vtkPythonInteractiveInterpreter* Interpreter;
116  const char* Prompt;
117  static QStringList Preamble;
118 
119  static const char* PS1() { return ">>> "; }
120  static const char* PS2() { return "... "; }
121 
124  void setupInterpreter();
125  friend class pqPythonManager;
126 
129  bool prompt(const QString& indent=QString());
130 
131  void HandleInterpreterEvents(
132  vtkObject* caller, unsigned long eventid, void* calldata);
133 
134 private:
135  Q_DISABLE_COPY(pqPythonShell)
136 
137  bool Prompted;
138  bool Executing;
139 };
140 
141 #endif // !_pqPythonShell_h
pqPythonShell is a QWidget subclass that provides an interactive Python shell.
Definition: pqPythonShell.h:51
void setExecuting(bool val)
bool isExecuting() const
Returns true is the shell is currently executing a script/command.
Definition: pqPythonShell.h:88
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