A groupbox QGroupBox can group widgets, it provides a frame, title on top and it can display a multiple of widgets inside. It typically has a title and a border. Any PyQt widget can be added into the group box. This can be further used to communciate your UI/UX to your user.
This example demonstrates how to create the groupbox as shown below:

Practice now: Test your Python skills with interactive challenges
QGroupBox
PyQt Groupbox
The groupbox is initialized with QGroupBox("title"). Using the constructor is the normal way to set the title (you can also set the alignment: top, bottom, left, right, center). A layout is then added to the groupbox. Widgets are added to the layout.
A QGroupBox doesn't layout the widgets automatically, so you have to do that yourself. You can use or QHBoxLayout for that.
A groupbox can be checkable. All of that said, that gives us the following initializiation:
groupbox = QGroupBox("GroupBox Example")
groupbox.setCheckable(True)
layout.addWidget(groupbox)
vbox = QVBoxLayout()
groupbox.setLayout(vbox)
Individual widgets can then be added to the QVBoxLayout.
vbox.addWidget(radiobutton)
vbox.addWidget(radiobutton)
vbox.addWidget(radiobutton)
...
This example below creates a checkable groupbox, title and with several widgets add to it
from PyQt5.QtWidgets import *
import sys
class GroupBox(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setWindowTitle("GroupBox")
layout = QGridLayout()
self.setLayout(layout)
groupbox = QGroupBox("GroupBox Example")
groupbox.setCheckable(True)
layout.addWidget(groupbox)
vbox = QVBoxLayout()
groupbox.setLayout(vbox)
radiobutton = QRadioButton("RadioButton 1")
vbox.addWidget(radiobutton)
radiobutton = QRadioButton("RadioButton 2")
vbox.addWidget(radiobutton)
radiobutton = QRadioButton("RadioButton 3")
vbox.addWidget(radiobutton)
radiobutton = QRadioButton("RadioButton 4")
vbox.addWidget(radiobutton)
app = QApplication(sys.argv)
screen = GroupBox()
screen.show()
sys.exit(app.exec_())
Practice now: Test your Python skills with interactive challenges
Practice now: Test your Python skills with interactive challenges