Class: QgsCodeEditorWidget¶
- class qgis.gui.QgsCodeEditorWidget¶
Bases:
QgsPanelWidget
A widget which wraps a
QgsCodeEditor
in additional functionality.This widget wraps an existing
QgsCodeEditor
object in a widget which provides additional standard functionality, such as search/replace tools. The caller must create an unparentedQgsCodeEditor
object (or a subclass ofQgsCodeEditor
) first, and then construct aQgsCodeEditorWidget
passing this object to the constructor.Note
may not be available in Python bindings, depending on platform support
Added in version 3.38.
QgsCodeEditorWidget(editor: Optional[QgsCodeEditor], messageBar: Optional[QgsMessageBar] = None, parent: Optional[QWidget] = None) Constructor for
QgsCodeEditorWidget
, wrapping the specifiededitor
widget.Ownership of
editor
will be transferred to this widget.If an explicit
messageBar
is specified then it will be used to provide feedback, otherwise an integrated message bar will be used.Methods
Adds a
warning
message and indicator to the specified alineNumber
.Clears all warning messages from the editor.
Returns the wrapped code editor.
- param obj:
Returns the widget's associated file path.
Hides the search bar.
Returns
True
if the search bar is visible.Overridden key press event to handle the esc event on the widget.
Loads the file at the specified
path
into the widget, replacing the code editor's content with that from the file.Returns the message bar associated with the widget, to use for user feedback.
Attempts to opens the script from the editor in an external text editor.
- param event:
Returns the scrollbar highlight controller, which can be used to add highlights in the code editor scrollbar.
Sets the widget's associated file
path
.Sets whether the replace bar is
visible
.Sets whether the search bar is
visible
.- param event:
Shows the search bar.
Triggers a find operation, using the default behavior.
- actionEvent(self, a0: QActionEvent | None)¶
- addWarning(self, lineNumber: int, warning: str | None)¶
Adds a
warning
message and indicator to the specified alineNumber
.This method calls
QgsCodeEditor.addWarning()
, but also automatically adds highlights to the widget scrollbars locating the warning location.See also
- Parameters:
lineNumber (int)
warning (Optional[str])
- changeEvent(self, a0: QEvent | None)¶
- childEvent(self, a0: QChildEvent | None)¶
- clearWarnings(self)¶
Clears all warning messages from the editor.
This method calls
QgsCodeEditor.clearWarnings()
, but also removes highlights from the widget scrollbars at the warning locations.See also
- closeEvent(self, a0: QCloseEvent | None)¶
- connectNotify(self, signal: QMetaMethod)¶
- contextMenuEvent(self, a0: QContextMenuEvent | None)¶
- create(self, window: PyQt5.sip.voidptr = None, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, a0: QEvent | None)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, signal: QMetaMethod)¶
- dragEnterEvent(self, a0: QDragEnterEvent | None)¶
- dragLeaveEvent(self, a0: QDragLeaveEvent | None)¶
- dragMoveEvent(self, a0: QDragMoveEvent | None)¶
- dropEvent(self, a0: QDropEvent | None)¶
- editor(self) QgsCodeEditor | None ¶
Returns the wrapped code editor.
- Return type:
Optional[QgsCodeEditor]
- enterEvent(self, a0: QEvent | None)¶
- event(self, a0: QEvent | None) bool ¶
- eventFilter(self, obj: QObject | None, event: QEvent | None) bool ¶
- Parameters:
obj (Optional[QObject])
event (Optional[QEvent])
- Return type:
bool
- filePath(self) str ¶
Returns the widget’s associated file path.
See also
See also
- Return type:
str
- filePathChanged¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...)
revision (int = ...)
arguments (Sequence = ...)
- Return type:
PYQT_SIGNAL
- focusInEvent(self, a0: QFocusEvent | None)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, next: bool) bool ¶
- focusOutEvent(self, a0: QFocusEvent | None)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, a0: QHideEvent | None)¶
- hideSearchBar(self)¶
Hides the search bar.
See also
See also
- initPainter(self, painter: QPainter | None)¶
- inputMethodEvent(self, a0: QInputMethodEvent | None)¶
- isSearchBarVisible(self) bool ¶
Returns
True
if the search bar is visible.- Return type:
bool
- isSignalConnected(self, signal: QMetaMethod) bool ¶
- keyPressEvent(self, event: QKeyEvent | None)¶
Overridden key press event to handle the esc event on the widget.
- Parameters:
event – The key event
- keyReleaseEvent(self, a0: QKeyEvent | None)¶
- leaveEvent(self, a0: QEvent | None)¶
- loadFile(self, path: str | None) bool ¶
Loads the file at the specified
path
into the widget, replacing the code editor’s content with that from the file.This automatically sets the widget’s
filePath()
Returns
True
if the file was loaded successfully.- Parameters:
path (Optional[str])
- Return type:
bool
- loadedExternalChanges¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...)
revision (int = ...)
arguments (Sequence = ...)
- Return type:
PYQT_SIGNAL
- messageBar(self) QgsMessageBar | None ¶
Returns the message bar associated with the widget, to use for user feedback.
- Return type:
Optional[QgsMessageBar]
- metric(self, a0: QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, a0: QMouseEvent | None)¶
- mouseMoveEvent(self, a0: QMouseEvent | None)¶
- mousePressEvent(self, a0: QMouseEvent | None)¶
- mouseReleaseEvent(self, a0: QMouseEvent | None)¶
- moveEvent(self, a0: QMoveEvent | None)¶
- nativeEvent(self, eventType: QByteArray | bytes | bytearray, message: PyQt5.sip.voidptr | None)¶
- openInExternalEditor(self, line: int = -1, column: int = -1) bool ¶
Attempts to opens the script from the editor in an external text editor.
This requires that the widget has an associated
filePath()
set.Optionally a target
line
andcolumn
number can be specified to open the editor at the corresponding location. (Not all external editors support this.) Line/column numbers of -1 indicate that the current cursor position should be used. Aline
number of 0 corresponds to the first line, and a column number of 0 corresponds to the first column.- Return type:
bool
- Returns:
True
if the file was opened successfully.- Parameters:
line (int = -1)
column (int = -1)
- paintEvent(self, a0: QPaintEvent | None)¶
- receivers(self, signal: PYQT_SIGNAL) int ¶
- resizeEvent(self, event: QResizeEvent | None)¶
- Parameters:
event (Optional[QResizeEvent])
- scrollbarHighlightController(self) QgsScrollBarHighlightController | None ¶
Returns the scrollbar highlight controller, which can be used to add highlights in the code editor scrollbar.
- Return type:
Optional[QgsScrollBarHighlightController]
- searchBarToggled¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...)
revision (int = ...)
arguments (Sequence = ...)
- Return type:
PYQT_SIGNAL
- sender(self) QObject | None ¶
- senderSignalIndex(self) int ¶
- setFilePath(self, path: str | None)¶
Sets the widget’s associated file
path
.See also
See also
See also
- Parameters:
path (Optional[str])
- setReplaceBarVisible(self, visible: bool)¶
Sets whether the replace bar is
visible
.See also
- Parameters:
visible (bool)
- setSearchBarVisible(self, visible: bool)¶
Sets whether the search bar is
visible
.See also
See also
See also
- Parameters:
visible (bool)
- showEvent(self, event: QShowEvent | None)¶
- Parameters:
event (Optional[QShowEvent])
- showSearchBar(self)¶
Shows the search bar.
See also
See also
- tabletEvent(self, a0: QTabletEvent | None)¶
- timerEvent(self, a0: QTimerEvent | None)¶
- triggerFind(self)¶
Triggers a find operation, using the default behavior.
This will automatically open the search bar and start a find operation using the default behavior, e.g. searching for any selected text in the code editor.
- updateMicroFocus(self)¶
- wheelEvent(self, a0: QWheelEvent | None)¶