ctkPythonConsole.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. /*=========================================================================
  15. Program: ParaView
  16. Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
  17. All rights reserved.
  18. ParaView is a free software; you can redistribute it and/or modify it
  19. under the terms of the ParaView license version 1.2.
  20. See http://www.paraview.org/paraview/project/license.html for the full ParaView license.
  21. A copy of this license can be obtained by contacting
  22. Kitware Inc.
  23. 28 Corporate Drive
  24. Clifton Park, NY 12065
  25. USA
  26. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
  30. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  31. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  32. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  33. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  34. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  36. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. =========================================================================*/
  38. #ifndef __ctkPythonConsole_h
  39. #define __ctkPythonConsole_h
  40. // CTK includes
  41. #include <ctkConsole.h>
  42. #include "ctkScriptingPythonWidgetsExport.h"
  43. ///
  44. /// Qt widget that provides an interactive "shell" interface to an embedded Python interpreter.
  45. /// You can put an instance of ctkPythonConsole in a dialog or a window, and the user will be able
  46. /// to enter Python commands and see their output, while the UI is still responsive.
  47. ///
  48. /// \sa ctkConsole
  49. class ctkPythonConsolePrivate;
  50. class ctkAbstractPythonManager;
  51. class CTK_SCRIPTING_PYTHON_WIDGETS_EXPORT ctkPythonConsole : public ctkConsole
  52. {
  53. Q_OBJECT
  54. public:
  55. typedef ctkConsole Superclass;
  56. ctkPythonConsole(QWidget* parentObject = 0);
  57. virtual ~ctkPythonConsole();
  58. /// Initialize
  59. void initialize(ctkAbstractPythonManager* newPythonManager);
  60. /// Returns the string used as primary prompt
  61. virtual QString ps1() const;
  62. /// Set the string used as primary prompt
  63. virtual void setPs1(const QString& newPs1);
  64. /// Returns the string used as secondary prompt
  65. virtual QString ps2() const;
  66. /// Set the string used as secondary prompt
  67. virtual void setPs2(const QString& newPs2);
  68. public slots:
  69. // void executeScript(const QString&);
  70. /// Reset ps1 and ps2, clear the console and print the welcome message
  71. virtual void reset();
  72. protected:
  73. virtual void executeCommand(const QString& command);
  74. private:
  75. Q_DECLARE_PRIVATE(ctkPythonConsole);
  76. Q_DISABLE_COPY(ctkPythonConsole);
  77. };
  78. #endif