Input dialog in PyQt is supported out of the box (QInputDialog
). This has an input text, an ok and cancel button.
In this article you’ll see that works in PyQt. As shown in the screenshot
Related Course: Create GUI Apps with Python PyQt5
Input Dialog
Example
The code below creates a PyQt input dialog. After you click the button, you can enter some text. The text is shown as label.
The dialog is created in the method showDialog
and it’s just a few lines. Input dialig is part of PyQt5.QtWidgets
.
1 | from PyQt5.QtWidgets import (QWidget, QPushButton, QLineEdit, QInputDialog, QApplication, QLabel) |
If you are new to Python PyQt, then I highly recommend this book.