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

Class CommandItem

SLiCAP/schematic/command_item.py:7–40  ·  view source on GitHub ↗

SLiCAP command block — one or more lines beginning with '.'. Each non-empty line is inserted verbatim into the netlist. Double-click to edit; Enter adds a new command line.

Source from the content-addressed store, hash-verified

5
6
7class CommandItem(QGraphicsTextItem):
8 """
9 SLiCAP command block — one or more lines beginning with '.'.
10 Each non-empty line is inserted verbatim into the netlist.
11 Double-click to edit; Enter adds a new command line.
12 """
13
14 def __init__(self, text: str = ".", pos: QPointF = QPointF(0, 0)):
15 super().__init__(text)
16 self.setPos(pos)
17 self.setFont(COMMAND_FONT)
18 self.setDefaultTextColor(COMMAND_COLOR)
19 self.setFlag(QGraphicsItem.ItemIsSelectable)
20 self.setFlag(QGraphicsItem.ItemIsMovable)
21 self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
22 self.setTextInteractionFlags(Qt.NoTextInteraction)
23
24 def itemChange(self, change, value):
25 if change == QGraphicsItem.ItemPositionChange:
26 return snap(value)
27 return super().itemChange(change, value)
28
29 def mouseDoubleClickEvent(self, event):
30 self.setTextInteractionFlags(Qt.TextEditorInteraction)
31 self.setFocus()
32 super().mouseDoubleClickEvent(event)
33
34 def focusOutEvent(self, event):
35 self.setTextInteractionFlags(Qt.NoTextInteraction)
36 super().focusOutEvent(event)
37
38 def commands(self) -> list[str]:
39 """Return each non-empty line as a netlist command string."""
40 return [ln for ln in self.toPlainText().splitlines() if ln.strip()]

Callers 3

_commit_pasteMethod · 0.85
from_dataMethod · 0.85
mousePressEventMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected