13. Rich Text and Printing
PyQt supports rich text, essentially a subset of HTML that also includes some support for CSS (cascading style sheets).* This means that in practice, we can pass strings that contain HTML markup to many of PyQt’s text-handling classes and rely on PyQt to render the HTML properly in the user interface.
We have already seen examples of passing HTML to QLabel
s. The graphics item class QGraphicsTextItem
can also accept HTML. The QTextBrowser
class supports basic HTML display including hyperlinks, and although it is by no means a full-blown Web browser, many developers find it sufficient for displaying help text. For editing HTML, PyQt provides the QTextEdit
class. Although this class ...
Get Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.