(self, config, parent=None)
| 428 | |
| 429 | class ConfigEditor(QtWidgets.QDialog): |
| 430 | def __init__(self, config, parent=None): |
| 431 | super().__init__(parent) |
| 432 | self.config = config |
| 433 | if config.endswith("config.yaml") and not config.endswith("pytorch_config.yaml"): |
| 434 | self.read_func = auxiliaryfunctions.read_config |
| 435 | self.write_func = auxiliaryfunctions.write_config |
| 436 | else: |
| 437 | self.read_func = auxiliaryfunctions.read_plainconfig |
| 438 | self.write_func = auxiliaryfunctions.write_plainconfig |
| 439 | self.cfg = self.read_func(config) |
| 440 | self.parent = parent |
| 441 | self.setWindowTitle("Configuration Editor") |
| 442 | if parent is not None: |
| 443 | self.setMinimumWidth(parent.screen_width // 2) |
| 444 | self.setMinimumHeight(parent.screen_height // 2) |
| 445 | self.viewer = DictViewer(self.cfg, config, self) |
| 446 | |
| 447 | self.save_button = QtWidgets.QPushButton("Save", self) |
| 448 | self.save_button.setDefault(True) |
| 449 | self.save_button.clicked.connect(self.accept) |
| 450 | self.cancel_button = QtWidgets.QPushButton("Cancel", self) |
| 451 | self.cancel_button.clicked.connect(self.close) |
| 452 | |
| 453 | vbox = QtWidgets.QVBoxLayout(self) |
| 454 | vbox.addWidget(self.viewer) |
| 455 | hbox = QtWidgets.QHBoxLayout() |
| 456 | hbox.addWidget(self.save_button) |
| 457 | hbox.addWidget(self.cancel_button) |
| 458 | vbox.addLayout(hbox) |
| 459 | |
| 460 | def keyPressEvent(self, e): |
| 461 | if e.key() == QtCore.Qt.Key_Escape: |
nothing calls this directly
no test coverage detected