Skip to content

Commit faa66bf

Browse files
committed
Expose declared function editor action identities
1 parent e30d0ba commit faa66bf

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎src/pyqt_reactive/widgets/function_list_editor.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,19 @@ def create_button(self, widget: FunctionListEditorWidget) -> QPushButton:
106106
"""Create one button directly from this action declaration."""
107107

108108
button = QPushButton(self.label)
109+
button.setObjectName(self.object_name)
109110
button.setMaximumWidth(self.maximum_width)
110111
button.setFixedHeight(CURRENT_LAYOUT.button_height)
111112
button.setStyleSheet(widget._get_button_style())
112113
button.clicked.connect(lambda _checked=False: self.invoke(widget))
113114
return button
114115

116+
@property
117+
def object_name(self) -> str:
118+
"""Return the declaration-derived Qt identity for this action."""
119+
120+
return f"function_list_editor_action_{self.value}"
121+
115122
def invoke(self, widget: FunctionListEditorWidget) -> None:
116123
"""Execute this action's leaf behavior."""
117124

‎tests/test_function_list_editor_tokens.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def test_function_editor_actions_own_labels_and_execution_leaves() -> None:
7474
1,
7575
]
7676
assert FunctionListEditorAction.ADD.label == "Add"
77+
assert (
78+
FunctionListEditorAction.ADD.object_name
79+
== "function_list_editor_action_add"
80+
)
7781

7882

7983
def _wrapped(func):

0 commit comments

Comments
 (0)