How to do it...

The QPainter class is the focus of this recipe. The setFont() and drawText() methods of the QPainter class will be used in this recipe. The setFont() method will be invoked to set the font style and font size chosen by the user and the drawText() method will draw the text written by the user in the Text Edit widget in the specified font style and size. Here is the step-by-step procedure to learn how these methods are used:

  1. Let's create an application based on the Dialog without Buttons template.
  1. Add the QLabel, QTextEdit, QListWidget, QComboBox, and QPushButton widgets to the form by dragging and dropping a Label widget, a Text Edit widget, a List Widget box, a Combo Box widget, and a Push Button widget on the form.
  2. Set ...

Get Python GUI Programming - A Complete Reference Guide 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.