Python command line interpreter front-end GUI widget. More...
#include <PyConsole_Editor.h>

Public Slots | |
| void | cut () |
| "Copy" operation. | |
| void | paste () |
| "Paste" operation. | |
| void | clear () |
| "Clear" operation. | |
| void | handleReturn () |
| Process "Enter" key press event. | |
| void | onPyInterpChanged (PyConsole_Interp *) |
| Handle Python interpreter change. | |
| void | dump () |
| "Dump commands" operation. | |
Public Member Functions | |
| PyConsole_Editor (PyConsole_Interp *theInterp, QWidget *theParent=0) | |
| Constructor. | |
| ~PyConsole_Editor () | |
| Destructor. | |
| virtual void | addText (const QString &str, const bool newBlock=false) |
| Put the string str to the python editor. | |
| bool | isCommand (const QString &str) const |
| Check if the string is command. | |
| virtual void | exec (const QString &command) |
| Convenient method for executing a Python command, as if the user typed it manually. | |
| void | execAndWait (const QString &command) |
| Execute command in the python interpreter and wait until it is finished. | |
| bool | isSync () const |
| Get synchronous mode flag value. | |
| void | setIsSync (const bool) |
| Set synchronous mode flag value. | |
| bool | isSuppressOutput () const |
| Get suppress output flag value. | |
| void | setIsSuppressOutput (const bool) |
| Set suppress output flag value. | |
| bool | isShowBanner () const |
| Get 'show banner' flag value. | |
| void | setIsShowBanner (const bool) |
| Set 'show banner' flag value. | |
| virtual QSize | sizeHint () const |
| Get size hint for the Python console window. | |
Protected Member Functions | |
| virtual void | dropEvent (QDropEvent *event) |
| Process drop event. | |
| virtual void | mouseReleaseEvent (QMouseEvent *event) |
| Process mouse button release event. | |
| virtual void | keyPressEvent (QKeyEvent *event) |
| Handle keyboard event. | |
| virtual void | customEvent (QEvent *event) |
| Handle notification event coming from Python dispatcher. | |
| virtual PyInterp_Request * | createRequest (const QString &) |
| Create request to the python dispatcher for the command execution. | |
Private Attributes | |
| PyConsole_Interp * | myInterp |
| python interpreter | |
| QString | myCommandBuffer |
| python command buffer | |
| QString | myCurrentCommand |
| currently being printed command | |
| QString | myPrompt |
| current command line prompt | |
| int | myCmdInHistory |
| current history command index | |
| QStringList | myHistory |
| commands history buffer | |
| QEventLoop * | myEventLoop |
| internal event loop | |
| QString | myBanner |
| current banner | |
| bool | myShowBanner |
| 'show banner' flag | |
| QStringList | myQueue |
| python commands queue | |
| bool | myIsSync |
| synchronous mode flag | |
| bool | myIsSuppressOutput |
| suppress output flag | |
This class provides simple GUI interface to the Python interpreter, including basic navigation operations, executing commands (both interactively and programmatically), copy-paste operations, history of the commands and so on.
Here below is the shortcut keyboard boundings used for navigation and other operations:
: copy<Ctrl><X> : cut<Ctrl><V> : paste TODO:
| PyConsole_Editor::PyConsole_Editor | ( | PyConsole_Interp * | theInterp, |
| QWidget * | theParent = 0 |
||
| ) |
Creates python editor window.
| theInterp | python interper |
| theParent | parent widget |
References myPrompt, onPyInterpChanged(), READY_PROMPT, PyInterp_Interp.setverrcb(), PyInterp_Interp.setvoutcb(), staticCallback(), and SUIT_Tools.stringToFont().
| PyConsole_Editor::~PyConsole_Editor | ( | ) |
Does nothing for the moment.
| void PyConsole_Editor::addText | ( | const QString & | str, |
| const bool | newBlock = false |
||
| ) | [virtual] |
| str | string to be put in the command line of the editor |
| newBlock | if True, then the string is printed on a new line |
| bool PyConsole_Editor::isCommand | ( | const QString & | str | ) | const |
Return True if the string str is likely to be the command (i.e. it is started from the '>>>' or '...').
| str | string to be checked |
References DOTS_PROMPT, and READY_PROMPT.
| void PyConsole_Editor::exec | ( | const QString & | command | ) | [virtual] |
| command | python command to be executed |
References addText(), TestSalomeApp.command, createRequest(), DOTS_PROMPT, PyInterp_Dispatcher.Exec(), PyInterp_Dispatcher.Get(), myCmdInHistory, myCommandBuffer, myHistory, myPrompt, myQueue, and READY_PROMPT.
| void PyConsole_Editor::execAndWait | ( | const QString & | command | ) |
| command | python command to be executed |
References exec(), and myEventLoop.
| bool PyConsole_Editor::isSync | ( | ) | const |
| void PyConsole_Editor::setIsSync | ( | const bool | on | ) |
In synhronous mode the Python commands are executed in the GUI thread and the GUI is blocked until the command is finished. In the asynchronous mode each Python command is executed in the separate thread that does not block the main GUI loop.
| on | synhronous mode flag |
References myIsSync.
| bool PyConsole_Editor::isSuppressOutput | ( | ) | const |
true if python console output is suppressed. References myIsSuppressOutput.
| void PyConsole_Editor::setIsSuppressOutput | ( | const bool | on | ) |
In case if suppress output flag is true, the python console output suppressed.
| on | suppress output flag |
References myIsSuppressOutput.
| bool PyConsole_Editor::isShowBanner | ( | ) | const |
| void PyConsole_Editor::setIsShowBanner | ( | const bool | on | ) |
The banner is shown in the top of the python console window.
| on | 'show banner' flag |
References clear(), and myShowBanner.
| QSize PyConsole_Editor::sizeHint | ( | ) | const [virtual] |
References isShowBanner(), and myBanner.
| void PyConsole_Editor::dropEvent | ( | QDropEvent * | event | ) | [protected, virtual] |
| void PyConsole_Editor::mouseReleaseEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Left mouse button: copy selection to the clipboard. Middle mouse button: paste clipboard's contents.
| event | mouse event |
References PROMPT_SIZE.
| void PyConsole_Editor::keyPressEvent | ( | QKeyEvent * | event | ) | [protected, virtual] |
Implement navigation, history browsing, copy/paste and other common operations.
| event | keyboard event |
References addText(), cut(), handleReturn(), isCommand(), myCmdInHistory, myCommandBuffer, myCurrentCommand, myHistory, myPrompt, paste(), PROMPT_SIZE, and READY_PROMPT.
| void PyConsole_Editor::customEvent | ( | QEvent * | event | ) | [protected, virtual] |
| event | notification event |
References addText(), DOTS_PROMPT, PyInterp_Event.ES_ERROR, PyInterp_Event.ES_INCOMPLETE, PyInterp_Event.ES_OK, exec(), myCmdInHistory, myCommandBuffer, myEventLoop, myPrompt, myQueue, PRINT_EVENT, READY_PROMPT, and PrintEvent.text().
| PyInterp_Request * PyConsole_Editor::createRequest | ( | const QString & | command | ) | [protected, virtual] |
| void PyConsole_Editor::cut | ( | ) | [slot] |
Reimplemented from Qt. Warning! In Qt4 this method is not virtual.
References PROMPT_SIZE.
| void PyConsole_Editor::paste | ( | ) | [slot] |
Reimplemented from Qt. Warning! In Qt4 this method is not virtual.
References PROMPT_SIZE.
| void PyConsole_Editor::clear | ( | ) | [slot] |
Reimplemented from Qt. Warning! In Qt4 this method is not virtual.
References addText(), isShowBanner(), myBanner, myPrompt, and READY_PROMPT.
| void PyConsole_Editor::handleReturn | ( | ) | [slot] |
Execute the command entered by the user.
References addText(), createRequest(), PyInterp_Dispatcher.Exec(), PyInterp_Dispatcher.Get(), myCommandBuffer, myHistory, and PROMPT_SIZE.
| void PyConsole_Editor::onPyInterpChanged | ( | PyConsole_Interp * | interp | ) | [slot] |
Perform initialization actions if the interpreter is changed.
| interp | python interpreter is being set |
References addText(), clear(), PyInterp_Interp.getbanner(), isShowBanner(), myBanner, myCmdInHistory, myCommandBuffer, myEventLoop, myInterp, and myPrompt.
| void PyConsole_Editor::dump | ( | ) | [slot] |
References SUIT_FileDlg.getFileName(), and myHistory.
PyConsole_Interp* PyConsole_Editor.myInterp [private] |
QString PyConsole_Editor.myCommandBuffer [private] |
QString PyConsole_Editor.myCurrentCommand [private] |
QString PyConsole_Editor.myPrompt [private] |
int PyConsole_Editor.myCmdInHistory [private] |
QStringList PyConsole_Editor.myHistory [private] |
QEventLoop* PyConsole_Editor.myEventLoop [private] |
QString PyConsole_Editor.myBanner [private] |
bool PyConsole_Editor.myShowBanner [private] |
QStringList PyConsole_Editor.myQueue [private] |
bool PyConsole_Editor.myIsSync [private] |
bool PyConsole_Editor.myIsSuppressOutput [private] |