MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / __init__

Method __init__

SLiCAP/schematic/attribute_dialog.py:20–47  ·  view source on GitHub ↗
(self, item: ComponentItem, prop_key: str, parent=None)

Source from the content-addressed store, hash-verified

18 """Edit one attribute (value + show-value/show-name) of a ComponentItem."""
19
20 def __init__(self, item: ComponentItem, prop_key: str, parent=None):
21 super().__init__(parent)
22 self._item = item
23 self._key = prop_key
24 self.setWindowTitle(f"{prop_key} — {item.instance_id}")
25
26 outer = QVBoxLayout(self)
27 grid = QGridLayout()
28 outer.addLayout(grid)
29
30 grid.addWidget(QLabel(prop_key), 0, 0)
31 self._edit = QLineEdit(self._current_value())
32 grid.addWidget(self._edit, 0, 1)
33
34 sv, sn = item.prop_display.get(prop_key, (False, False))
35 self._sv = QCheckBox("Show value")
36 self._sn = QCheckBox("Show name")
37 self._sv.setChecked(sv)
38 self._sn.setChecked(sn)
39 self._sn.setEnabled(sv)
40 self._sv.toggled.connect(self._on_show_value)
41 grid.addWidget(self._sv, 1, 1)
42 grid.addWidget(self._sn, 2, 1)
43
44 buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
45 buttons.accepted.connect(self.accept)
46 buttons.rejected.connect(self.reject)
47 outer.addWidget(buttons)
48
49 def _on_show_value(self, on: bool) -> None:
50 self._sn.setEnabled(on)

Callers

nothing calls this directly

Calls 1

_current_valueMethod · 0.95

Tested by

no test coverage detected