Python PyQt5 CHECKBOXES are easy! ✅

Published: 27 July 2024
on channel: Bro Code
3,138
74

#pythontutorial #python #pythonprogramming
PyQt5 Checkboxes
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QCheckBox
from PyQt5.QtCore import Qt

class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(700, 300, 500, 500)
self.checkbox = QCheckBox("Do you like food?", self)
self.initUI()

def initUI(self):
self.checkbox.setGeometry(10, 0, 500, 100)
self.checkbox.setStyleSheet("font-size: 30px;"
"font-family: Arial;")
self.checkbox.stateChanged.connect(self.checkbox_changed)

def checkbox_changed(self, state):
if state == Qt.Checked:
print("You like food")
else:
print("You DO NOT like food")

if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())


Watch video Python PyQt5 CHECKBOXES are easy! ✅ online, duration hours minute second in high quality that is uploaded to the channel Bro Code 27 July 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 3,138 times and liked it 74 visitors.