Subgroup: Expression
Class: QgsExpressionBuilderWidget¶
-
class
qgis.gui.
QgsExpressionBuilderWidget
(parent: QWidget = None)¶ Bases:
PyQt5.QtWidgets.QWidget
Create a new expression builder widget with an optional parent.
A reusable widget that can be used to build a expression string. See QgsExpressionBuilderDialog for example of usage.
Methods
actionEvent
autosave
Auto save the current Python function code. changeEvent
childEvent
closeEvent
connectNotify
contextMenuEvent
create
customEvent
destroy
disconnectNotify
dragEnterEvent
dragLeaveEvent
dragMoveEvent
dropEvent
enterEvent
evalError
Will be set to true if the current expression text reported an eval error with the context. event
expressionContext
Returns the expression context for the widget. expressionText
Gets the expression string that has been set in the expression area. focusInEvent
focusNextChild
focusNextPrevChild
focusOutEvent
focusPreviousChild
hideEvent
initPainter
inputMethodEvent
isExpressionValid
isSignalConnected
keyPressEvent
keyReleaseEvent
leaveEvent
loadAllValues
Load all unique values from the set layer into the sample area loadCodeFromFile
Load code from the given file into the function editor loadFieldNames
Loads all the field names from the layer. loadFieldsAndValues
Loads field names and values from the specified map. loadFunctionCode
Load code into the function editor loadRecent
Loads the recent expressions from the given collection. loadSampleValues
Load sample values into the sample value area metric
model
Returns a pointer to the dialog’s function item model. mouseDoubleClickEvent
mouseMoveEvent
mousePressEvent
mouseReleaseEvent
moveEvent
nativeEvent
newFunctionFile
Create a new file in the function editor paintEvent
parserError
Will be set to true if the current expression text reports a parser error with the context. project
Returns the project currently associated with the widget. receivers
registerItem
Registers a node item for the expression builder. resizeEvent
saveFunctionFile
Save the current function editor text to the given file. saveToRecent
Adds the current expression to the given collection. sender
senderSignalIndex
setAutoSave
Enabled or disable auto saving. setExpressionContext
Sets the expression context for the widget. setExpressionText
Sets the expression string for the widget setGeomCalculator
Sets geometry calculator used in distance/area calculations. setLayer
Sets layer in order to get the fields and values setProject
Sets the project
currently associated with the widget.sharedPainter
showEvent
tabletEvent
timerEvent
updateFunctionFileList
Update the list of function files found at the given path updateMicroFocus
wheelEvent
Signals
evalErrorChanged
Will be set to true if the current expression text reported an eval error with the context. expressionParsed
Emitted when the user changes the expression in the widget. parserErrorChanged
Will be set to true if the current expression text reported a parser error with the context. Attributes
-
actionEvent
()¶
-
autosave
(self)¶ Auto save the current Python function code.
-
changeEvent
()¶
-
childEvent
()¶
-
closeEvent
()¶
-
connectNotify
()¶
-
contextMenuEvent
()¶
-
create
()¶
-
customEvent
()¶
-
destroy
()¶
-
disconnectNotify
()¶
-
dragEnterEvent
()¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
dropEvent
()¶
-
enterEvent
()¶
-
evalError
(self) → bool¶ Will be set to true if the current expression text reported an eval error with the context.
New in version 3.0.
-
evalErrorChanged
¶ Will be set to true if the current expression text reported an eval error with the context.
New in version 3.0: [signal]
-
event
()¶
-
expressionContext
(self) → QgsExpressionContext¶ Returns the expression context for the widget. The context is used for the expression preview result and for populating the list of available functions and variables.
See also
New in version 2.12.
-
expressionParsed
¶ Emitted when the user changes the expression in the widget. Users of this widget should connect to this signal to decide if to let the user continue.
Parameters: isValid – Is true if the expression the user has typed is valid. [signal]
-
expressionText
(self) → str¶ Gets the expression string that has been set in the expression area.
Returns: The expression as a string. *
-
focusInEvent
()¶
-
focusNextChild
()¶
-
focusNextPrevChild
()¶
-
focusOutEvent
()¶
-
focusPreviousChild
()¶
-
hideEvent
()¶
-
initPainter
()¶
-
inputMethodEvent
()¶
-
isExpressionValid
(self) → bool¶
-
isSignalConnected
()¶
-
keyPressEvent
()¶
-
keyReleaseEvent
()¶
-
leaveEvent
()¶
-
loadAllValues
(self)¶ Load all unique values from the set layer into the sample area
-
loadCodeFromFile
(self, path: str)¶ Load code from the given file into the function editor
-
loadFieldNames
(self)¶ Loads all the field names from the layer. @remarks Should this really be public couldn’t we just do this for the user?
loadFieldNames(self, fields: QgsFields)
-
loadFieldsAndValues
(self, fieldValues: Dict[str, Iterable[str]])¶ Loads field names and values from the specified map.
Note
The field values must be quoted appropriately if they are strings.
New in version 2.12.
-
loadFunctionCode
(self, code: str)¶ Load code into the function editor
-
loadRecent
(self, collection: str = '')¶ Loads the recent expressions from the given collection. By default it is loaded from the collection “generic”.
-
loadSampleValues
(self)¶ Load sample values into the sample value area
-
metric
()¶
-
model
(self) → QStandardItemModel¶ Returns a pointer to the dialog’s function item model. This method is exposed for testing purposes only - it should not be used to modify the model.
New in version 3.0.
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
()¶
-
mousePressEvent
()¶
-
mouseReleaseEvent
()¶
-
moveEvent
()¶
-
nativeEvent
()¶
-
newFunctionFile
(self, fileName: str = '')¶ Create a new file in the function editor
-
paintEvent
()¶
-
parserError
(self) → bool¶ Will be set to true if the current expression text reports a parser error with the context.
New in version 3.0.
-
parserErrorChanged
¶ Will be set to true if the current expression text reported a parser error with the context.
New in version 3.0: [signal]
-
project
(self) → QgsProject¶ Returns the project currently associated with the widget.
See also
New in version 3.0.
-
receivers
()¶
-
registerItem
(self, group: str, label: str, expressionText: str, helpText: str = '', type: QgsExpressionItem.ItemType = QgsExpressionItem.ExpressionNode, highlightedItem: bool = False, sortOrder: int = 1)¶ Registers a node item for the expression builder.
Parameters: - group – The group the item will be show in the tree view. If the group doesn’t exsit it will be created.
- label – The label that is show to the user for the item in the tree.
- expressionText – The text that is inserted into the expression area when the user double clicks on the item.
- helpText – The help text that the user will see when item is selected.
- type – The type of the expression item.
- highlightedItem – set to true to make the item highlighted, which inserts a bold copy of the item at the top level
- sortOrder – sort ranking for item
-
resizeEvent
()¶
-
saveFunctionFile
(self, fileName: str)¶ Save the current function editor text to the given file.
-
saveToRecent
(self, collection: str = '')¶ Adds the current expression to the given collection. By default it is saved to the collection “generic”.
-
sender
()¶
-
senderSignalIndex
()¶
-
setAutoSave
(self, enabled: bool)¶ Enabled or disable auto saving. When enabled Python scripts will be auto saved when text changes.
Parameters: enabled – True to enable auto saving.
-
setExpressionContext
(self, context: QgsExpressionContext)¶ Sets the expression context for the widget. The context is used for the expression preview result and for populating the list of available functions and variables.
Parameters: context – expression context See also
New in version 2.12.
-
setExpressionText
(self, expression: str)¶ Sets the expression string for the widget
-
setGeomCalculator
(self, da: QgsDistanceArea)¶ Sets geometry calculator used in distance/area calculations.
-
setLayer
(self, layer: QgsVectorLayer)¶ Sets layer in order to get the fields and values
Note
this needs to be called before calling loadFieldNames().
-
setProject
(self, project: QgsProject)¶ Sets the
project
currently associated with the widget. This controls which layers and relations and other project-specific items are shown in the widget.See also
New in version 3.0.
-
showEvent
(self, e: QShowEvent)¶
-
tabletEvent
()¶
-
timerEvent
()¶
-
updateFunctionFileList
(self, path: str)¶ Update the list of function files found at the given path
-
updateMicroFocus
()¶
-
wheelEvent
()¶
-