def generate_files_ui(req_files, opt_files): v_box = QVBoxLayout() v_box.addWidget(QLabel('Required Files: ')) # loop through all required and options files to create GUI components for lbl in req_files.keys(): h_box = QHBoxLayout() h_box.addWidget(QLabel(lbl)) temp_combo = QComboBox() temp_combo.name = lbl temp_combo.addItem('None') h_box.addWidget(temp_combo) v_box.addLayout(h_box) v_box.addStretch() v_box.addWidget(QLabel('Optional Files: ')) # loop through all required and options files to create GUI components for lbl in opt_files.keys(): h_box = QHBoxLayout() h_box.addWidget(QLabel(lbl)) temp_combo = QComboBox() temp_combo.name = lbl temp_combo.addItem('None') h_box.addWidget(temp_combo) v_box.addLayout(h_box) v_box.addStretch() return v_box
def initData(self, cdict): self.options = cdict num = len(cdict) self.topFiller.setMinimumSize(400, 40 * num + 50) maxh = 40 * num + 50 > 500 and 500 or 40 * num + 50 self.setFixedHeight(maxh) oWidget = QWidget(self.topFiller) mm = QVBoxLayout() oWidget.setLayout(mm) index = 0 self.opcombox = [] for op in self.options: if self.getDictValue(op, 'default') != "": m = QHBoxLayout() a = QLabel() a.setFixedWidth(200) a.setText(op['label']) if self.getDictValue(op, "hover"): a.setToolTip(op['hover']) m.addWidget(a) if self.getDictValue(op, 'options'): b = QComboBox() b.select = True b.index = index b.name = op['name'] self.opcombox.append(b) b.setFixedWidth(150) b.setStyleSheet( "QComboBox QAbstractItemView::item { min-height: 25px; min-width: 100px; }" ) b.setItemDelegate(QStyledItemDelegate()) b.currentIndexChanged.connect(self.selectChange) bd = [] for o in op['options']: b.addItem(str(o['description'])) bd.append(o['data']) b.data = bd if self.getDictValue(op['options'][b.currentIndex()], 'hover'): b.setToolTip(op['options'][b.currentIndex()]['hover']) else: b = QLabel() self.opcombox.append(b) b.select = False b.name = op['name'] b.data = op['default'] b.setText("请直接修改modinfo.lua") m.addWidget(b) mm.addLayout(m) index += 1 self.loadExistValue()