The rubberband module¶
Rubberband selection in a View.
-
class
Rubberband
[source]¶ Bases:
PyQt5.QtWidgets.QWidget
A Rubberband to select a rectangular region.
A Rubberband is added to a View with view.setRubberband().
The Rubberband lets the user select a rectangular region. When the selection is changed, the selectionChanged signal is emitted, having the selection rectangle in layout coordinates as argument.
Instance variables:
showbutton
(Qt.RightButton)the button used to drag a new rectangle
dragbutton
(Qt.LeftButton)the button to alter an existing rectangle
trackSelection
(False)whether to continuously emit selectionChanged(). When True,
selectionChanged()
is emitted on every change, when False, the signal is only emitted when the mouse button is released.
-
selectionChanged
¶
-
trackSelection
= False¶
-
selectedPages
()[source]¶ Yield tuples (page, rect) describing the selection.
Every rect is intersected with the page rect and translated to the page’s position.
-
selectedPage
()[source]¶ Returns (page, rect) if there is a selection.
If the selection contains more pages, the largest intersection is chosen. If no meaningful area is selected, (None, None) is returned.
-
selectedImage
(resolution=None, paperColor=None)[source]¶ Returns an image of the selected part on a Page.
If resolution is None, the displayed size is chosen. Otherwise, the resolution is an integer, interpreted as DPI (dots per inch).
-
selectedLinks
()[source]¶ Yield tuples (page, links) for every page in the selection.
links is a non-empty set() of Link instances on that page that intersect with the selection.
-
setSelection
(rect)[source]¶ Sets the selection, the rectangle should be relative to the view’s layout position.
-
eventFilter
(viewport, ev)[source]¶ Act on events in the viewport:
keep on the same place when the viewport resizes
start dragging the selection if showbutton clicked (preventing the contextmenu if the showbutton is the right button)
end a drag on mousebutton release, if that button would have shown the context menu, show it on button release.