Textedit Plain Text

The QTextEdit class is a multi-line text box control that displays multiple lines of text, with multiple vertical scrollbars when the text is outside the control’s display range.

  1. Textedit Default Plain Text
  2. Textedit Plain Text Generator

With TextEdit in focus, select Format → Make Plain Text option in the Menu bar or use the keyboard shortcut Shift + Command + T to change the file encoding to plain text. This will also set the extension of unsaved file to.TXT from the default.RTF. PyQt QTextEdit example. The QTextEdit class is a multi-line text box control that displays multiple lines of text, with multiple vertical scrollbars when the text is outside the control’s display range. It has several functions: setPlainText toPlainText setHtml toHtml.

Textedit Default Plain Text

It has several functions:

It can contain one or more lines and each line is split using the newline character n.

Book: Create Desktop Apps with Python PyQt5

Textedit Plain Text

QTextbox example

The example below shows a multiline textbox. You can click the buttons to change the text.

A textbox can be set with plain text .setPlainText() or with html setHTML().

Textedit Plain Text Generator

The code for this program is:

Code analysis:

Import the QTextEdit from PyQt

Create the textbox:

Add it to the window:

To set plain text in the QTextEdit:

Textedit plain text editor

To set html in the QTextEdit:

Book: Create Desktop Apps with Python PyQt5