The highlight module¶
Highlight rectangular areas inside a View.
A Highlighter can draw rectangles to highlight e.g. links in a View.
An instance represents a certain type of highlighting, e.g. of a particular style. The paintRects() method is called with a list of rectangles that need to be drawn.
To implement different highlighting behaviour just inherit paintRects(). The default implementation of paintRects() uses the color attribute to get the color to use and the lineWidth (default: 2) and radius (default: 3) attributes.
lineWidth specifies the thickness in pixels of the border drawn, radius specifies the distance in pixels the border is drawn (by default with rounded corners) around the area to be highlighted. color is set to None by default, causing the paintRects method to choose the application’s palette highlight color.
Override this method to implement different drawing behaviour.
Mixin methods vor view.View for highlighting areas.
This mixin allows for highlighting rectangular areas on pages. You can highlight different sets of areas independently, using different Highlighter instances.
Highlighting can be set to stay on forever or to disappear after a certain amount of microseconds.
If desired, the View can be scrolled to show the highlighted areas. How the highlighting is drawn is determined by the paintRects() method of Highlighter.
Return a default highlighter, creating it if necessary.
Set a Highlighter to use as the default highlighter.
Return the bounding rect of the areas.
highlight(areas, highlighter=None, msec=0, scroll=False, margins=None, allowKinetic=True)¶
Highlight the areas dict using the given or default highlighter.
The areas dict maps Page objects to lists of rectangles, where the rectangle is a QRectF() inside (0, 0, 1, 1) like the area attribute of a Link.
If the highlighter is not specified, the default highlighter will be used.
If msec > 0, the highlighting will vanish after that many microseconds.
If scroll is True, the View will be scrolled to show the areas to highlight if needed, using View.ensureVisible(highlightRect(areas), margins, allowKinetic).
Removes the highlighted areas of the given or default highlighter.
Return True if the given or default highlighter is active.
highlightUrls(urls, highlighter=None, msec=0, scroll=False, margins=None, allowKinetic=True)¶
Convenience method highlighting the specified urls in the Document.
The urls argument is a list of urls (str); the other arguments are used for calling highlight() on the areas returned by getUrlHighlightAreas(urls).
Return the areas to highlight all occurrences of the specified URLs.
The areas are found in the dictionary returned by document().urls(). URLs that are not in that dictionary are silently skipped. If there is no document set this method returns nothing.
Paint the highlighted areas in the viewport.