pqPythonShell.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqPythonShell_h
5 #define pqPythonShell_h
6 
7 #include "pqPythonModule.h" // needed for PQPYTHON_EXPORT.
8 #include <QScopedPointer> // needed for QScopedPointer.
9 #include <QWidget>
10 
11 class vtkObject;
12 class pqConsoleWidget;
13 
33 class PQPYTHON_EXPORT pqPythonShell : public QWidget
34 {
35  Q_OBJECT
36  typedef QWidget Superclass;
37 
38 public:
39  pqPythonShell(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags{});
40  ~pqPythonShell() override;
41 
47  void* consoleLocals();
48 
50 
53  void setFontSize(int fontSize);
55 
56  enum PrintMode
57  {
60  ERROR
61  };
62 
63 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
67  void printMessage(const QString&);
68 
73  void clear();
74 
79  void executeScript(const QString&);
80 
86  void reset();
87 
91  bool isExecuting() const;
92 
98  void printString(const QString&, PrintMode mode = STATUS);
99 
107  static void setPreamble(const QStringList& statements);
108  static const QStringList& preamble();
109 
114  void initialize();
115 
116 Q_SIGNALS:
122  void executing(bool starting);
123 
124 protected Q_SLOTS:
125  void pushScript(const QString&);
126  void runScript();
127 
128 protected: // NOLINT(readability-redundant-access-specifiers)
130  const char* Prompt;
131  static QStringList Preamble;
132 
133  static const char* PS1() { return ">>> "; }
134  static const char* PS2() { return "... "; }
135 
140  bool prompt(const QString& indent = QString());
141 
142  void HandleInterpreterEvents(vtkObject* caller, unsigned long eventid, void* calldata);
143 
144 private:
145  Q_DISABLE_COPY(pqPythonShell)
146  bool Prompted;
147 
148  class pqInternals;
149  friend class pqInternals;
150  QScopedPointer<pqInternals> Internals;
151 };
152 
153 #endif // !pqPythonShell_h
Widget for a Python shell.
Definition: pqPythonShell.h:33
#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