The magnifier module

The Magnifier magnifies a part of the displayed document.

class Magnifier[source]

Bases: PyQt5.QtWidgets.QWidget

A Magnifier is added to a View with view.setMagnifier().

It is shown when a mouse button is pressed together with a modifier (by default Ctrl). It can then be resized by moving the mouse is with two buttons pressed, or by wheeling with resizemodifier pressed.

Its size can be changed with resize() and the scale (defaulting to 3.0) with setScale().

If can also be shown programatically with the show() method. In this case it can be dragged with the left mouse button.

Wheel zooming with the modifier (by default Ctrl) zooms the magnifier.

Instance attributes:

showmodifier:

the modifier to popup (Qt.ControlModifier)

zoommodifier:

the modifier to wheel zoom (Qt.ControlModifier)

resizemodifier:

the key to press for wheel resizing (Qt.ShiftModifier)

showbutton:

the mouse button causing the magnifier to popup (by default Qt.LeftButton)

resizebutton:

the extra mouse button to be pressed when resizing the magnifier (by default Qt.RightButton)

MAX_EXTRA_ZOOM:

the maximum zoom (relative to the View’s maximum zoom level)

showmodifier = 67108864
zoommodifier = 67108864
resizemodifier = 33554432
showbutton = 1
resizebutton = 2
MAX_EXTRA_ZOOM = 1.25
MIN_SIZE = 50
MAX_SIZE = 640
moveCenter(pos)[source]

Called by the View, centers the widget on the given QPoint.

setScale(scale)[source]

Sets the scale, relative to the dislayed size in the View.

scale()[source]

Returns the scale, defaulting to 3.0 (=300%).

startShortDrag(pos)[source]

Start a short drag (e.g. on ctrl+click).

endShortDrag()[source]

End a short drag.

startLongDrag(pos)[source]

Start a long drag (when we are already visible and then dragged).

endLongDrag()[source]

End a long drag.

resizeEvent(ev)[source]

Called on resize, sets our circular mask.

moveEvent(ev)[source]

Called on move, updates the contents.

eventFilter(viewport, ev)[source]

Handle events on the viewport of the View.

mousePressEvent(ev)[source]

Start dragging the magnifier.

mouseMoveEvent(ev)[source]

Move the magnifier if we were dragging it.

mouseReleaseEvent(ev)[source]

The button is released, stop moving ourselves.

wheelEvent(ev)[source]

Implement zooming the magnifying glass.

paintEvent(ev)[source]

Called when paint is needed, finds out which page to magnify.

drawBorder(painter)[source]

Draw a nice looking glass border.

repaintPage(page)[source]

Called when a Page was rendered in the background.