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. By default, it auto-saves only its collapsed state to the global settings based on the widget and it’s parent names. Holding Alt modifier key when toggling collapsed state will synchronize the toggling across other collapsible group boxes with the same syncGroup QString value Holding Shift modifier key when attempting to toggle collapsed state will expand current group box, then collapse any others with

QgsCollapsibleGroupBoxBasic

A groupbox that collapses/expands when toggled. Basic class QgsCollapsibleGroupBoxBasic does not auto-save collapsed or checked state Holding Alt modifier key when toggling collapsed state will synchronize the toggling across other collapsible group boxes with the same syncGroup QString value Holding Shift modifier key when attempting to toggle collapsed state will expand current group box, then collapse any others with the same syncGroup QString value

QGroupBox

QWidget

QObject

QPaintDevice

Methods

currentCrs

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

currentExtent

Returns the current extent set for the widget.

extentState

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

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.

ratio

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

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.

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.

setTitleBase

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

titleBase

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

Signals

extentChanged

Emitted when the widget's extent is changed.

Attributes

CurrentExtent

DrawOnCanvas

OriginalExtent

ProjectLayerExtent

UserExtent

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(r: QgsRectangle)[source]

Emitted when the widget’s extent is changed.

Parameters:

r (QgsRectangle)

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