In this PyQt5 tutorial, I will be covering how to use a QGroupBox widget to organize your widgets.

What is PyQt?

PyQt is a library created by Riverbank based on the Qt framework to let you build desktop applications in Python. (An alternative is PySide2, by Qt the company itself).

Qt framework itself is written in C++, and the framework is also available in other programming languages, such as Java and C++. By using Python, we can build applications much more rapidly.

🔔 Subscribe: https://www.youtube.com/channel/UCvVZ19DRSLIC2-RUOeWx8ug

Source Code


import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QCheckBox, QGroupBox


class MyApp(QWidget):
	def __init__(self):
		super().__init__()
		self.setWindowTitle('Group Checkbox with QGroupBox Widget')
		self.setMinimumWidth(600)

		layout = QVBoxLayout()
		self.setLayout(layout)

		groupBox = QGroupBox('My GroupBox')
		groupBox.setCheckable(True)
		layout.addWidget(groupBox)

		groupBoxLayout = QVBoxLayout()
		groupBox.setLayout(groupBoxLayout)

		for i in range(5):
			groupBoxLayout.addWidget(QCheckBox('Checkbox {0}'.format(i)))

if __name__ == '__main__':
	app = QApplication(sys.argv)
	app.setStyleSheet('''
		QWidget {
			font-size: 35px;
		}
	''')
	
	myApp = MyApp()
	myApp.show()

	try:
		sys.exit(app.exec_())
	except SystemExit:
		print('Closing Window...')


#python #pyqt5

How To Organize Your Widgets With Groupbox Widget | PyQt5 Tutorial
7.05 GEEK