
- PyQt - Home
- PyQt - Introduction
- PyQt - Environment
- PyQt - Hello World
- PyQt - Major Classes
- PyQt - Using Qt Designer
- PyQt - Meta Objects
- PyQt Signals & Slots
- PyQt - Signals and Slots
- PyQt - Support and Signals
- PyQt - Unbound and Bound Signals
- PyQt - New Signals with PyQtSignal
- PyQt - Connecting, Disconnecting, & Emitting Signals
- PyQt - Slot decorator
- PyQt - Slot Connection
- PyQt Layouts
- PyQt - Layout Management
- PyQt - QBoxLayout
- PyQt - QGridLayout
- PyQt - QFormLayout
- PyQt - QHBoxLayout
- PyQt - QVBoxLayout
- PyQt - QStackedLayout
- PyQt - QGraphicsGridLayout
- PyQt - QGraphicsAnchorLayout
- PyQt - QGraphicsLayout
- PyQt - QGraphicsLinearLayout
- PyQt Basic Widgets
- PyQt - Basic Widgets
- PyQt - Qlabel Widget
- PyQt - QLineEdit Widget
- PyQt - QPushButton Widget
- PyQt - QRadioButton Widget
- PyQt - QCheckBox Widget
- PyQt - QComboBox Widget
- PyQt - QSpinBox Widget
- PyQt - QMessageBox
- PyQt - QDialogButtonBox Widget
- PyQt - QFontComboBox Widget
- PyQt - QDoubleSpinBox Widget
- PyQt - QToolBox Widget
- PyQt - QMenuBar, QMenu & Qaction Widgets
- PyQt - QToolTip
- PyQt - QInputDialog Widget
- PyQt - QFontDialog Widget
- PyQt - QDialog Widget
- PyQt - QFileDialog Widget
- PyQt - QTab Widget
- PyQt - QSplitter Widget
- PyQt - QDock Widget
- PyQt - QStatusBar Widget
- PyQt - QTabBar
- PyQt - QList Widget
- PyQt - QScrollBar Widget
- PyQt - QProgressBar
- PyQt - QCalendar Widget
- PyQt - QMessageBox Widget
- PyQt - QPlainTextEdit
- PyQt - QDateEdit
- PyQt - QDateTimeEdit
- PyQt - QTimeEdit
- PyQt - QTextEdit
- PyQt - QTextBrowser
- PyQt - QScrollArea
- PyQt - Drag and Drop
- PyQt - Multiple Document Interface
- PyQt - QDialog Class
- PyQt Views
- PyQt - QColumnView
- PyQt - QTableView
- PyQt Drawing API
- PyQt - Drawing API
- PyQt - Drawing a Line
- PyQt - Drawing a Rectangle
- PyQt - Drawing a Triangle
- PyQt - Drawing a Circle
- PyQt - Drawing a Ellipse
- PyQt - Drawing a Polygon
- PyQt - Geometric Transformation
- PyQt - Drawing Effect
- PyQt Groups
- PyQt - QButtonGroup
- PyQt - QGroupBox
- PyQt Effects
- PyQt - Effects
- PyQt - Opacity Effect
- PyQt - QGraphicsBlur Effect
- PyQt - QGraphicsColorize Effect
- PyQt - QGraphicsDropShadow Effect
- PyQt Events
- PyQt - Event Handling
- PyQt - Drag & Drop Events
- PyQt - File Open Event
- PyQt - Action Event
- PyQt - Hide Event
- PyQt - Resize Event
- PyQt Database
- PyQt - Database Handling
- PyQt Essentials
- PyQt - BrushStyle Constants
- PyQt - QClipboard
- PyQt - QPixmap Class
- PyQt Useful Resources
- PyQt - Quick Guide
- PyQt - Useful Resources
- PyQt - Discussion
PyQt - Basic Widgets
PyQt widgets are graphical elements that are used to create user interfaces in PyQt applications. These widgets are used for various purposes, such as displaying information, accepting user input, or providing controls for interaction. PyQt offers a wide range of pre-built widgets that developers can use to build desktop applications efficiently.
Here is the list of Widgets which we will discuss one by one in this chapter.
Sr.No | Widgets & Description |
---|---|
1 |
QLabel
A QLabel object acts as a placeholder to display non-editable text or image, or a movie of animated GIF. It can also be used as a mnemonic key for other widgets. |
2 |
QLineEdit
QLineEdit object is the most commonly used input field. It provides a box in which one line of text can be entered. In order to enter multi-line text, QTextEdit object is required. |
3 |
QPushButton
In PyQt API, the QPushButton class object presents a button which when clicked can be programmed to invoke a certain function. |
4 |
QRadioButton
A QRadioButton class object presents a selectable button with a text label. The user can select one of many options presented on the form. This class is derived from QAbstractButton class. |
5 |
QCheckBox
A rectangular box before the text label appears when a QCheckBox object is added to the parent window. Just as QRadioButton, it is also a selectable button. |
6 |
QComboBox
A QComboBox object presents a dropdown list of items to select from. It takes minimum screen space on the form required to display only the currently selected item. |
7 |
QSpinBox
A QSpinBox object presents the user with a textbox which displays an integer with up/down button on its right. |
8 |
QSlider Widget & Signal
QSlider class object presents the user with a groove over which a handle can be moved. It is a classic widget to control a bounded value. |
9 |
QMenuBar, QMenu & QAction
A horizontal QMenuBar just below the title bar of a QMainWindow object is reserved for displaying QMenu objects. |
10 |
QToolBar
A QToolBar widget is a movable panel consisting of text buttons, buttons with icons or other widgets. |
11 |
QInputDialog
This is a preconfigured dialog with a text field and two buttons, OK and Cancel. The parent window collects the input in the text box after the user clicks on Ok button or presses Enter. |
12 |
QFontDialog
Another commonly used dialog, a font selector widget is the visual appearance of QDialog class. Result of this dialog is a Qfont object, which can be consumed by the parent window. |
13 |
QFileDialog
This widget is a file selector dialog. It enables the user to navigate through the file system and select a file to open or save. The dialog is invoked either through static functions or by calling exec_() function on the dialog object. |
14 |
QTab
If a form has too many fields to be displayed simultaneously, they can be arranged in different pages placed under each tab of a Tabbed Widget. The QTabWidget provides a tab bar and a page area. |
15 |
QStacked
Functioning of QStackedWidget is similar to QTabWidget. It also helps in the efficient use of windows client area. |
16 |
QSplitter
If a form has too many fields to be displayed simultaneously, they can be arranged in different pages placed under each tab of a Tabbed Widget. The QTabWidget provides a tab bar and a page area. |
17 |
QDock
A dockable window is a subwindow that can remain in floating state or can be attached to the main window at a specified position. Main window object of QMainWindow class has an area reserved for dockable windows. |
18 |
QStatusBar
QMainWindow object reserves a horizontal bar at the bottom as the status bar. It is used to display either permanent or contextual status information. |
19 |
QList
QListWidget class is an item-based interface to add or remove items from a list. Each item in the list is a QListWidgetItem object. ListWidget can be set to be multiselectable. |
20 |
QScrollBar
A scrollbar control enables the user to access parts of the document that is outside the viewable area. It provides visual indicator to the current position. |
21 |
QCalendar
QCalendar widget is a useful date picker control. It provides a month-based view. The user can select the date by the use of the mouse or the keyboard, the default being todays date. |
Advantages of Widgets in PyQt
- Rich Set of Pre-built Widgets − PyQt provides a vast array of pre-built widgets that cover a wide range of functionalities, from basic input fields to complex data visualization components. This extensive library saves developers time and effort by offering ready-made solutions for common UI elements.
- Cross-Platform Compatibility − PyQt widgets are designed to work easily across multiple platforms, including Windows, macOS, Linux, and various mobile platforms. This cross-platform compatibility makes sure that applications developed using PyQt can be deployed to a diverse range of devices without much modifications.
- Customization Options − PyQt widgets are highly customizable, which helps us to change the appearance and behavior of UI components to suit the specific requirements. Properties such as color, size, font, and alignment can be easily adjusted using PyQt's API, which help developers to create visually appealing and user-friendly interfaces.
- Active Community and Support − PyQt has a very active community of developers who contribute to its development, provide support, and share knowledge through forums, mailing lists, and online resources. This community-driven ecosystem ensures that developers have access to a all the expertise and assistance when working with PyQt.
- Performance and Efficiency − PyQt is built on top of the Qt framework, which is known for its high performance and efficiency. PyQt applications has a fast response time and consume minimal system resources, making them suitable for a wide range of use cases.
Some example of Basic Widgets
QLabel
import sys from PyQt5.QtWidgets import QApplication, QLabel app = QApplication(sys.argv) label = QLabel('Hello, World!') label.show() sys.exit(app.exec_())
Output
The above code produces the following output −

QLineEdit
import sys from PyQt5.QtWidgets import QApplication, QLineEdit app = QApplication(sys.argv) line_edit = QLineEdit() line_edit.show() sys.exit(app.exec_())
Output
The above code produces the following output −

QPushButton
import sys from PyQt5.QtWidgets import QApplication, QPushButton app = QApplication(sys.argv) button = QPushButton('Click me') button.show() sys.exit(app.exec_())
Output
The above code produces the following output −

We will learn all these Widgets in details in the next few chapters.