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

Method __init__

SLiCAP/schematic/properties_dialog.py:36–166  ·  view source on GitHub ↗
(self, item: ComponentItem, parent=None)

Source from the content-addressed store, hash-verified

34 """
35
36 def __init__(self, item: ComponentItem, parent=None):
37 super().__init__(parent, Qt.Window)
38 self._item = item
39 self.setWindowTitle(f"Properties — {item.instance_id}")
40
41 outer = QVBoxLayout()
42 outer.setSizeConstraint(QLayout.SetFixedSize)
43 self.setLayout(outer)
44
45 # ── description + clickable info link (from the symbol's data-* meta) ──
46 desc = SYMBOL_DESCRIPTION.get(item.symbol_name, "")
47 info = SYMBOL_INFO.get(item.symbol_name, "")
48 if desc or info:
49 head = QLabel()
50 head.setTextFormat(Qt.RichText)
51 head.setOpenExternalLinks(True) # open the link in the browser
52 head.setWordWrap(True)
53 head.setMaximumWidth(360)
54 lines = []
55 if desc:
56 from .symbol_library import description_to_html
57 lines.append(description_to_html(desc))
58 if info:
59 url = html.escape(info, quote=True)
60 lines.append(f'<a href="{url}">{html.escape(info)}</a>')
61 head.setText("<br>".join(lines))
62 outer.addWidget(head)
63 outer.addWidget(_hline())
64
65 # ── single grid for all property rows ─────────────────────────────────
66 # Using one shared QGridLayout ensures columns 2 & 3 (checkboxes) align
67 # across headers, refdes, model and params rows.
68 self._grid = QGridLayout()
69 self._grid.setColumnStretch(1, 1)
70 self._grid.setColumnMinimumWidth(2, 72)
71 self._grid.setColumnMinimumWidth(3, 72)
72
73 # Headers
74 for col, text in enumerate(("<b>Property</b>", "<b>Value</b>",
75 "<b>Show val.</b>", "<b>Show name</b>")):
76 lbl = QLabel(text)
77 if col >= 2:
78 lbl.setAlignment(Qt.AlignCenter)
79 self._grid.addWidget(lbl, _HDR_ROW, col)
80 self._grid.addWidget(_hline(), _SEP_ROW, 0, 1, 4)
81
82 # Refdes row
83 self._ref_edit = QLineEdit(item.instance_id)
84 sv_ref, sn_ref = item.prop_display.get("refdes", (True, False))
85 self._ref_sv, self._ref_sn = _make_pair(sv_ref, sn_ref)
86 self._grid.addWidget(QLabel("refdes"), _REFDES_ROW, 0)
87 self._grid.addWidget(self._ref_edit, _REFDES_ROW, 1)
88 self._grid.addWidget(self._ref_sv, _REFDES_ROW, 2, Qt.AlignCenter)
89 self._grid.addWidget(self._ref_sn, _REFDES_ROW, 3, Qt.AlignCenter)
90
91 # Model row — a free text field: the model is the SLiCAP model name (or,
92 # for an X block, the subcircuit name) and the user must be able to type
93 # any value, not just pick from the symbol's single data-model default.

Callers

nothing calls this directly

Calls 8

_rebuild_paramsMethod · 0.95
_rebuild_refsMethod · 0.95
_descendMethod · 0.95
description_to_htmlFunction · 0.85
_make_pairFunction · 0.85
available_modelsFunction · 0.85
textMethod · 0.80
_hlineFunction · 0.70

Tested by

no test coverage detected