PyQt5 provides a class named QInputDialog which is used to take input from the user. In most of the application, there comes a situation where some data is required to be entered by the user and hence input dialog is needed. Input can be of type String or Text, Integer, Double and item.
These methods return tuple having two elements – User input and Status, whether user clicked “ok”(true) or “cancel”(false) button after providing desired input.
- getText(): This is used to take Text value from the user.
- getInt(): This is used to take integer value from the user.
- getDouble(): This is used to take Double value from the user.
- getItem(): This is used to take the selected item from mulitiple choice by the user.
Let us create a simple application using QInputDialog where a Main Window will appear having a button “Proceed”. After clicking that button multiple input dialogs will open asking for name, roll, CGPA and learned programming language from a list of languages.
Finally, Main Window will give a confirmation message along with the details provided by user.
Below is the Code –
Click “Proceed” button.
Give the details.
Confirmation message along with user data.
- PyQt5 QColorDialog - Getting Color Dialog Options
- PyQt5 QColorDialog - Testing Color Dialog Options
- PyQt5 QColorDialog - Setting Color Dialog Options
- PyQt5 QColorDialog - Setting Multiple Color Dialog Options
- Python - Tkinter askquestion Dialog
- Python - Tkinter Choose color Dialog
- Raise a File Download Dialog Box in Python
- PyQt5 QCalendarWidget -Grabbing Keyboard input
- PyQt5 QCalendarWidget - Grabbing Mouse Input
- PyQt5 QSpinBox - Stopping key board input
- PyQt5 QSpinBox - Getting input method hints
- PyQt5 QCalendarWidget - Input Method Query Property
- PyQt5 QSpinBox - Setting input method hints
- PyQt5 QCalendarWidget - Releasing Grabbed Keyboard input
- PyQt5 QCalendarWidget - Releasing Grabbed Mouse Input
- PyQt5 QCalendarWidget - Getting Input Method Hints Property
- PyQt5 QCalendarWidget - Setting Input Method Hints Property
- Take input from stdin in Python
- fileinput.input() in Python
- Taking input in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.