Loading src/gui.py +19 −9 Original line number Diff line number Diff line Loading @@ -148,18 +148,13 @@ class Ui(QtWidgets.QMainWindow): for element in tconf['elements']: element:dict try: shortcut = '' if 'shortcut' in element.keys(): shortcut = element['shortcut'] eid = element['id'] wid = f"rb_{eid}" # radiobutton widget = QtWidgets.QRadioButton(None) widget.setObjectName(wid) widget.setSizePolicy(QtWidgets.QSizePolicy(policy.Minimum, policy.Fixed)) widget.setText(f"{element['name']}") widget.setShortcut(shortcut) addRadioButtonTexts() addToolTip(widget, element) gbb.addButton(widget) Loading @@ -171,10 +166,10 @@ class Ui(QtWidgets.QMainWindow): self.rbNames.append(wid) # shortcut label if shortcut != '': if 'shortcut' in element.keys(): widget = QtWidgets.QLabel(None) widget.setSizePolicy(QtWidgets.QSizePolicy(policy.Preferred, policy.Preferred)) widget.setText(f"[{shortcut}]") widget.setText(f"[{element['shortcut']}]") gb.layout().addWidget(widget, count//cols, count%cols) count += 1 except KeyError as e: Loading Loading @@ -556,3 +551,18 @@ def addCheckBoxTexts(widget: QtWidgets.QCheckBox, element:dict) -> None: widget.setShortcut(shortcut) text = f"[{shortcut}] {name}" widget.setText(text) def addRadioButtonTexts(widget: QtWidgets.QRadioButton, element:dict) -> None: id, name, shortcut = None, None, None try: id = element['id'] name = element['name'] shortcut = element['shortcut'] except KeyError as e: if name is None: name = id.capitalize() print(e) finally: if shortcut is not None: widget.setShortcut(shortcut) widget.setText(name) No newline at end of file Loading
src/gui.py +19 −9 Original line number Diff line number Diff line Loading @@ -148,18 +148,13 @@ class Ui(QtWidgets.QMainWindow): for element in tconf['elements']: element:dict try: shortcut = '' if 'shortcut' in element.keys(): shortcut = element['shortcut'] eid = element['id'] wid = f"rb_{eid}" # radiobutton widget = QtWidgets.QRadioButton(None) widget.setObjectName(wid) widget.setSizePolicy(QtWidgets.QSizePolicy(policy.Minimum, policy.Fixed)) widget.setText(f"{element['name']}") widget.setShortcut(shortcut) addRadioButtonTexts() addToolTip(widget, element) gbb.addButton(widget) Loading @@ -171,10 +166,10 @@ class Ui(QtWidgets.QMainWindow): self.rbNames.append(wid) # shortcut label if shortcut != '': if 'shortcut' in element.keys(): widget = QtWidgets.QLabel(None) widget.setSizePolicy(QtWidgets.QSizePolicy(policy.Preferred, policy.Preferred)) widget.setText(f"[{shortcut}]") widget.setText(f"[{element['shortcut']}]") gb.layout().addWidget(widget, count//cols, count%cols) count += 1 except KeyError as e: Loading Loading @@ -556,3 +551,18 @@ def addCheckBoxTexts(widget: QtWidgets.QCheckBox, element:dict) -> None: widget.setShortcut(shortcut) text = f"[{shortcut}] {name}" widget.setText(text) def addRadioButtonTexts(widget: QtWidgets.QRadioButton, element:dict) -> None: id, name, shortcut = None, None, None try: id = element['id'] name = element['name'] shortcut = element['shortcut'] except KeyError as e: if name is None: name = id.capitalize() print(e) finally: if shortcut is not None: widget.setShortcut(shortcut) widget.setText(name) No newline at end of file