Class: QgsExtentGroupBox

Collapsible group box for configuration of extent, typically for a save operation.

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 group box, make sure to call setOriginalExtent(), setCurrentExtent() and setOutputCrs() during initialization.

See also

QgsExtentWidget

Class Hierarchy

Inheritance diagram of qgis.gui.QgsExtentGroupBox

Base classes

QgsCollapsibleGroupBox

A groupbox that collapses/expands when toggled and can save its collapsed and checked states.

QgsCollapsibleGroupBoxBasic

A groupbox that collapses/expands when toggled.

QGroupBox

QWidget

QObject

QPaintDevice

class qgis.gui.QgsExtentGroupBox[source]

Bases: QgsCollapsibleGroupBox

__init__(parent: QWidget | None = None)

Constructor for QgsExtentGroupBox.

Parameters:

parent (Optional[QWidget] = None)

CurrentExtent = 1
DrawOnCanvas = 4
class ExtentState

Bases: int

OriginalExtent = 0
ProjectLayerExtent = 3
UserExtent = 2
currentCrs(self) QgsCoordinateReferenceSystem[source]

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[source]

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

signal extentChanged[source]

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.

signal extentLayerChanged[source]

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.

extentState(self) QgsExtentGroupBox.ExtentState[source]

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

Return type:

QgsExtentGroupBox.ExtentState

originalCrs(self) QgsCoordinateReferenceSystem[source]

Returns the original coordinate reference system set for the widget.

See also

originalExtent()

Return type:

QgsCoordinateReferenceSystem

originalExtent(self) QgsRectangle[source]

Returns the original extent set for the widget.

See also

originalCrs()

Return type:

QgsRectangle

outputCrs(self) QgsCoordinateReferenceSystem[source]

Returns the current output CRS, used in the display.

See also

outputExtent()

Return type:

QgsCoordinateReferenceSystem

outputExtent(self) QgsRectangle[source]

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

See also

outputCrs()

Return type:

QgsRectangle

ratio(self) QSize[source]

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

setCurrentExtent(self, currentExtent: QgsRectangle, currentCrs: QgsCoordinateReferenceSystem)[source]

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 | None, drawOnCanvasOption: bool = True)[source]

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

Parameters:
  • canvas (Optional[QgsMapCanvas]) – the map canvas

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

setOriginalExtent(self, originalExtent: QgsRectangle, originalCrs: QgsCoordinateReferenceSystem)[source]

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)[source]

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)[source]

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

setOutputExtentFromDrawOnCanvas(self)[source]

Sets the output extent by dragging on the canvas.

setOutputExtentFromLayer(self, layer: QgsMapLayer | None)[source]

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

Parameters:

layer (Optional[QgsMapLayer])

setOutputExtentFromOriginal(self)[source]

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

setOutputExtentFromUser(self, extent: QgsRectangle, crs: QgsCoordinateReferenceSystem)[source]

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

Parameters:
setRatio(self, ratio: QSize)[source]

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

setTitleBase(self, title: str | None)[source]

Sets the base part of title of the group box (will be appended with extent state)

See also

titleBase()

Parameters:

title (Optional[str])

titleBase(self) str[source]

Returns the base part of title of the group box (will be appended with extent state).

See also

setTitleBase()

Return type:

str