I want to dynamically add checkboxes for every file in a directory but when there's more than 10 files it just looks awful. So I need advice on how to tell the program that it should only add 5 checkboxes into one row and then move to the other. Thank you in advance.
class Ui_schnittDialog(object):
def setupUi(self, schnittDialog):
schnittDialog.setObjectName("schnittDialog")
schnittDialog.resize(500, 300)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(schnittDialog.sizePolicy().hasHeightForWidth())
schnittDialog.setSizePolicy(sizePolicy)
schnittDialog.setStyleSheet("")
self.groupQuelleZiel = QtWidgets.QGroupBox(schnittDialog)
self.groupQuelleZiel.setGeometry(QtCore.QRect(11, 4, 481, 51))
self.groupQuelleZiel.setObjectName("groupQuelleZiel")
self.displayQuelle = QtWidgets.QLineEdit(self.groupQuelleZiel)
self.displayQuelle.setGeometry(QtCore.QRect(10, 19, 201, 21))
self.displayQuelle.setStyleSheet("QLineEdit *le = new QLineEdit();
"
"le->setStyleSheet("QLineEdit { background: rgb(0, 255, 255); selection-background-color: rgb(233, 99, 0); }");")
self.displayQuelle.setReadOnly(True)
self.displayQuelle.setObjectName("displayQuelle")
self.displayZiel = QtWidgets.QLineEdit(self.groupQuelleZiel)
self.displayZiel.setGeometry(QtCore.QRect(230, 19, 221, 21))
self.displayZiel.setStyleSheet("")
self.displayZiel.setReadOnly(True)
self.displayZiel.setObjectName("displayZiel")
self.checkBoxFrame = QtWidgets.QFrame(schnittDialog)
self.checkBoxFrame.setGeometry(QtCore.QRect(20, 80, 461, 161))
self.checkBoxFrame.setStyleSheet("")
self.checkBoxFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.checkBoxFrame.setFrameShadow(QtWidgets.QFrame.Raised)
self.checkBoxFrame.setObjectName("checkBoxFrame")
self.line_2 = QtWidgets.QFrame(self.checkBoxFrame)
self.line_2.setGeometry(QtCore.QRect(0, 0, 461, 3))
self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.line_3 = QtWidgets.QFrame(self.checkBoxFrame)
self.line_3.setGeometry(QtCore.QRect(0, 0, 3, 161))
self.line_3.setFrameShape(QtWidgets.QFrame.VLine)
self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_3.setObjectName("line_3")
self.gridLayoutWidget = QtWidgets.QWidget(self.checkBoxFrame)
self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 10, 441, 141))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.line = QtWidgets.QFrame(schnittDialog)
self.line.setGeometry(QtCore.QRect(20, 240, 461, 3))
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.line_4 = QtWidgets.QFrame(schnittDialog)
self.line_4.setGeometry(QtCore.QRect(480, 80, 3, 161))
self.line_4.setFrameShape(QtWidgets.QFrame.VLine)
self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_4.setObjectName("line_4")
for files in dir:
self.gridLayout.addWidget(QtWidgets.QCheckBox(files))
self.okButton = QtWidgets.QPushButton(schnittDialog)
self.okButton.setGeometry(QtCore.QRect(145, 260, 75, 23))
self.okButton.setObjectName("okButton")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…