MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / NetLabelDialog

Class NetLabelDialog

SLiCAP/schematic/net_label_dialog.py:8–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class NetLabelDialog(QDialog):
9 def __init__(self, current_name: str | None, display: bool,
10 locked: bool = False, parent=None):
11 super().__init__(parent, Qt.Window)
12 self.setWindowTitle("Net Label")
13 self.setMinimumWidth(280)
14
15 outer = QVBoxLayout()
16 outer.setSizeConstraint(QLayout.SetFixedSize)
17 self.setLayout(outer)
18
19 form = QFormLayout()
20 self._name_edit = QLineEdit(current_name or "")
21
22 if locked:
23 self._name_edit.setEnabled(False) # disables input and greys out reliably
24 form.addRow("Net name (port):", self._name_edit)
25 outer.addLayout(form)
26 note = QLabel("Name is set by the connected port and cannot be changed.")
27 note.setWordWrap(True)
28 note.setAlignment(Qt.AlignLeft)
29 note.setStyleSheet("color: grey; font-style: italic;")
30 outer.addWidget(note)
31 else:
32 self._name_edit.setPlaceholderText("leave blank for auto-number")
33 form.addRow("Net name:", self._name_edit)
34 outer.addLayout(form)
35
36 self._display_cb = QCheckBox("Display net name on schematic")
37 self._display_cb.setChecked(display)
38 outer.addWidget(self._display_cb)
39
40 buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
41 buttons.accepted.connect(self.accept)
42 buttons.rejected.connect(self.reject)
43 outer.addWidget(buttons)
44
45 if not locked:
46 self._name_edit.setFocus()
47 else:
48 self._display_cb.setFocus()
49
50 def net_name(self) -> str | None:
51 text = self._name_edit.text().strip()
52 return text if text else None
53
54 def display(self) -> bool:
55 return self._display_cb.isChecked()

Callers 1

_open_net_labelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected