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 <QScopedPointer> // needed for QScopedPointer.
37 #include <QWidget>
38 
39 class vtkObject;
40 class pqConsoleWidget;
41 
61 class PQPYTHON_EXPORT pqPythonShell : public QWidget
62 {
63  Q_OBJECT
64  typedef QWidget Superclass;
65 
66 public:
67  pqPythonShell(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags{});
68  ~pqPythonShell() override;
69 
75  void* consoleLocals();
76 
78 
81  void setFontSize(int fontSize);
83 
84  enum PrintMode
85  {
88  ERROR
89  };
90 
91 public Q_SLOTS:
95  void printMessage(const QString&);
96 
101  void clear();
102 
107  void executeScript(const QString&);
108 
114  void reset();
115 
119  bool isExecuting() const;
120 
126  void printString(const QString&, PrintMode mode = STATUS);
127 
135  static void setPreamble(const QStringList& statements);
136  static const QStringList& preamble();
137 
142  void initialize();
143 
144 Q_SIGNALS:
150  void executing(bool starting);
151 
152 protected Q_SLOTS:
153  void pushScript(const QString&);
154  void runScript();
155 
156 protected:
158  const char* Prompt;
159  static QStringList Preamble;
160 
161  static const char* PS1() { return ">>> "; }
162  static const char* PS2() { return "... "; }
163 
168  bool prompt(const QString& indent = QString());
169 
170  void HandleInterpreterEvents(vtkObject* caller, unsigned long eventid, void* calldata);
171 
172 private:
173  Q_DISABLE_COPY(pqPythonShell)
174  bool Prompted;
175 
176  class pqInternals;
177  friend class pqInternals;
178  QScopedPointer<pqInternals> Internals;
179 };
180 
181 #endif // !_pqPythonShell_h
Widget for a Python shell.
Definition: pqPythonShell.h:61
#define PQPYTHON_EXPORT
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()
pqConsoleWidget * ConsoleWidget
static QStringList Preamble