Class: QgsExtentWidget

class qgis.gui.QgsExtentWidget

Bases: PyQt5.QtWidgets.QWidget

A widget for configuration of a map extent.

Besides allowing the user to enter the extent manually, it comes with options to use original extent or extent defined by the current view in map canvas.

When using the widget, make sure to call setOriginalExtent(), setCurrentExtent() and setOutputCrs() during initialization.

New in version 3.14.

QgsExtentWidget(parent: QWidget = None, style: QgsExtentWidget.WidgetStyle = QgsExtentWidget.CondensedStyle) Constructor for QgsExtentWidget.

Methods

actionEvent

changeEvent

childEvent

clear

Clears the widget, setting it to a null value.

closeEvent

connectNotify

contextMenuEvent

create

currentCrs

Returns the coordinate reference system for the current extent set for the widget.

currentExtent

Returns the current extent set for the widget.

customEvent

destroy

disconnectNotify

dragEnterEvent

param event:

dragLeaveEvent

param event:

dragMoveEvent

dropEvent

param event:

enterEvent

event

extentLayerName

Returns the name of the extent layer.

extentState

Returns the currently selected state for the widget's extent.

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

inputMethodEvent

isSignalConnected

isValid

Returns True if the widget is in a valid state, i.e. has an extent set.

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

originalCrs

Returns the original coordinate reference system set for the widget.

originalExtent

Returns the original extent set for the widget.

outputCrs

Returns the current output CRS, used in the display.

outputExtent

Returns the extent shown in the widget - in output CRS coordinates.

paintEvent

ratio

Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.

receivers

resizeEvent

sender

senderSignalIndex

setCurrentExtent

Sets the current extent to show in the widget - should be called as part of initialization (or whenever current extent changes).

setMapCanvas

Sets the map canvas to enable dragging of extent on a canvas.

setNullValueAllowed

Sets whether the widget can be set to a "not set" (null) state.

setOriginalExtent

Sets the original extent and coordinate reference system for the widget.

setOutputCrs

Sets the output CRS - may need to be used for transformation from original/current extent.

setOutputExtentFromCurrent

Sets the output extent to be the same as current extent (may be transformed to output CRS).

setOutputExtentFromDrawOnCanvas

Sets the output extent by dragging on the canvas.

setOutputExtentFromLayer

Sets the output extent to match a layer's extent (may be transformed to output CRS).

setOutputExtentFromOriginal

Sets the output extent to be the same as original extent (may be transformed to output CRS).

setOutputExtentFromUser

Sets the output extent to a custom extent (may be transformed to output CRS).

setRatio

Sets a fixed aspect ratio to be used when dragging extent onto the canvas.

sharedPainter

showEvent

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

Signals

extentChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

toggleDialogVisibility

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

validationChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

Attributes

CondensedStyle

CurrentExtent

DrawOnCanvas

ExpandedStyle

OriginalExtent

ProjectLayerExtent

UserExtent

CondensedStyle = 0
CurrentExtent = 1
DrawOnCanvas = 4
ExpandedStyle = 1
class ExtentState

Bases: int

OriginalExtent = 0
ProjectLayerExtent = 3
UserExtent = 2
class WidgetStyle

Bases: int

actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
clear(self)

Clears the widget, setting it to a null value.

closeEvent(self, QCloseEvent)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
currentCrs(self) QgsCoordinateReferenceSystem

Returns the coordinate reference system for the current extent set for the widget. The current extent and CRS usually reflects the map canvas extent and CRS.

See also

currentExtent()

Return type:

QgsCoordinateReferenceSystem

currentExtent(self) QgsRectangle

Returns the current extent set for the widget. The current extent is usually set to match the current map canvas extent.

See also

currentCrs()

Return type:

QgsRectangle

customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, event: QDragEnterEvent)
Parameters:

event (QDragEnterEvent) –

dragLeaveEvent(self, event: QDragLeaveEvent)
Parameters:

event (QDragLeaveEvent) –

dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, event: QDropEvent)
Parameters:

event (QDropEvent) –

enterEvent(self, QEvent)
event(self, QEvent) bool
extentChanged

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

extentLayerName(self) str

Returns the name of the extent layer.

Return type:

str

extentState(self) QgsExtentWidget.ExtentState

Returns the currently selected state for the widget’s extent.

Return type:

QgsExtentWidget.ExtentState

focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
hideEvent(self, QHideEvent)
initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
isSignalConnected(self, QMetaMethod) bool
isValid(self) bool

Returns True if the widget is in a valid state, i.e. has an extent set.

Return type:

bool

keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
originalCrs(self) QgsCoordinateReferenceSystem

Returns the original coordinate reference system set for the widget.

See also

originalExtent()

Return type:

QgsCoordinateReferenceSystem

originalExtent(self) QgsRectangle

Returns the original extent set for the widget.

See also

originalCrs()

Return type:

QgsRectangle

outputCrs(self) QgsCoordinateReferenceSystem

Returns the current output CRS, used in the display.

See also

outputExtent()

Return type:

QgsCoordinateReferenceSystem

outputExtent(self) QgsRectangle

Returns the extent shown in the widget - in output CRS coordinates.

See also

outputCrs()

Return type:

QgsRectangle

paintEvent(self, QPaintEvent)
ratio(self) QSize

Returns the current fixed aspect ratio to be used when dragging extent onto the canvas. If the aspect ratio isn’t fixed, the width and height will be set to zero.

Return type:

QSize

receivers(self, PYQT_SIGNAL) int
resizeEvent(self, QResizeEvent)
sender(self) QObject
senderSignalIndex(self) int
setCurrentExtent(self, currentExtent: QgsRectangle, currentCrs: QgsCoordinateReferenceSystem)

Sets the current extent to show in the widget - should be called as part of initialization (or whenever current extent changes). The current extent is usually set to match the current map canvas extent.

See also

currentExtent()

See also

currentCrs()

Parameters:
setMapCanvas(self, canvas: QgsMapCanvas, drawOnCanvasOption: bool = True)

Sets the map canvas to enable dragging of extent on a canvas.

Parameters:
  • canvas (QgsMapCanvas) – the map canvas

  • drawOnCanvasOption (bool = True) – set to false to disable to draw on canvas option

setNullValueAllowed(self, allowed: bool, notSetText: str = '')

Sets whether the widget can be set to a “not set” (null) state.

The specified notSetText will be used for showing null values.

Note

This mode only applies to widgets in the condensed state!

Parameters:
  • allowed (bool) –

  • notSetText (str = '') –

setOriginalExtent(self, originalExtent: QgsRectangle, originalCrs: QgsCoordinateReferenceSystem)

Sets the original extent and coordinate reference system for the widget. This should be called as part of initialization.

See also

originalExtent()

See also

originalCrs()

Parameters:
setOutputCrs(self, outputCrs: QgsCoordinateReferenceSystem)

Sets the output CRS - may need to be used for transformation from original/current extent. Should be called as part of initialization and whenever the the output CRS is changed. The current extent will be reprojected into the new output CRS.

Parameters:

outputCrs (QgsCoordinateReferenceSystem) –

setOutputExtentFromCurrent(self)

Sets the output extent to be the same as current extent (may be transformed to output CRS).

setOutputExtentFromDrawOnCanvas(self)

Sets the output extent by dragging on the canvas.

setOutputExtentFromLayer(self, layer: QgsMapLayer)

Sets the output extent to match a layer’s extent (may be transformed to output CRS).

Parameters:

layer (QgsMapLayer) –

setOutputExtentFromOriginal(self)

Sets the output extent to be the same as original extent (may be transformed to output CRS).

setOutputExtentFromUser(self, extent: QgsRectangle, crs: QgsCoordinateReferenceSystem)

Sets the output extent to a custom extent (may be transformed to output CRS).

Parameters:
setRatio(self, ratio: QSize)

Sets a fixed aspect ratio to be used when dragging extent onto the canvas. To unset a fixed aspect ratio, set the width and height to zero.

Parameters:

ratio (QSize) – aspect ratio’s width and height

sharedPainter(self) QPainter
showEvent(self, QShowEvent)
tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
toggleDialogVisibility

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

updateMicroFocus(self)
validationChanged

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

wheelEvent(self, QWheelEvent)