본문 바로가기

공부/Python

4.[check box]Qt Designer + PyQt5

반응형

check box 4개를 뙁뙁뙁뙁

 

pyuic5 -x check_box.ui -o check_box_ui.py

 

import sys
from PyQt5.QtWidgets import *
import check_box_ui

class MyWindow(QMainWindow, check_box_ui.Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.checkBox.stateChanged.connect(self.box_funtion)
        self.checkBox_2.stateChanged.connect(self.box_funtion)
        self.checkBox_3.stateChanged.connect(self.box_funtion)
        self.checkBox_4.stateChanged.connect(self.box_funtion)

    def box_funtion(self):
        if self.checkBox.isChecked():
            print("check box1")
        if self.checkBox_2.isChecked():
            print("check box2")
        if self.checkBox_3.isChecked():
            print("check box3")
        if self.checkBox_4.isChecked():
            print("check box4")


if __name__ == "__main__":
    app = QApplication(sys.argv)
    myApp = MyWindow()
    myApp.show()
    app.exec_()

 

반응형

'공부 > Python' 카테고리의 다른 글

6.[Scroll Area]Qt Designer + PyQt5  (0) 2021.05.25
5.[Text]Qt Designer + PyQt5  (0) 2021.05.07
3.[Radio Button]Qt Designer + PyQt5  (0) 2021.05.07
2.[Dialog]Qt Designer + PyQt5  (0) 2021.05.06
1.[Button]Qt Designer + PyQt5  (0) 2021.05.06