Skip to content

Commit

Permalink
Add Component.description to use as label tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed May 22, 2024
1 parent e7289cb commit c61385b
Show file tree
Hide file tree
Showing 19 changed files with 192 additions and 3 deletions.
98 changes: 98 additions & 0 deletions schemas/pvi.device.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,22 @@
}
],
"default": null,
"description": "Label for component",
"title": "Label"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Description for label tooltip",
"title": "Description"
},
"pv": {
"description": "Child device PVI PV",
"title": "Pv",
Expand Down Expand Up @@ -278,8 +292,22 @@
}
],
"default": null,
"description": "Label for component",
"title": "Label"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Description for label tooltip",
"title": "Description"
},
"layout": {
"description": "How to layout children on screen",
"oneOf": [
Expand Down Expand Up @@ -467,8 +495,22 @@
}
],
"default": null,
"description": "Label for component",
"title": "Label"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Description for label tooltip",
"title": "Description"
},
"read_pv": {
"description": "PV to use for readback",
"title": "Read Pv",
Expand Down Expand Up @@ -539,8 +581,22 @@
}
],
"default": null,
"description": "Label for component",
"title": "Label"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Description for label tooltip",
"title": "Description"
},
"write_pv": {
"description": "PV to use for demand",
"title": "Write Pv",
Expand Down Expand Up @@ -644,8 +700,22 @@
}
],
"default": null,
"description": "Label for component",
"title": "Label"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Description for label tooltip",
"title": "Description"
},
"type": {
"const": "SignalRef",
"default": "SignalRef",
Expand Down Expand Up @@ -682,8 +752,22 @@
}
],
"default": null,
"description": "Label for component",
"title": "Label"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Description for label tooltip",
"title": "Description"
},
"write_pv": {
"description": "PV to use for demand",
"title": "Write Pv",
Expand Down Expand Up @@ -753,8 +837,22 @@
}
],
"default": null,
"description": "Label for component",
"title": "Label"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Description for label tooltip",
"title": "Description"
},
"write_pv": {
"description": "PV to use for demand",
"title": "Write Pv",
Expand Down
1 change: 1 addition & 0 deletions src/pvi/_format/dls.bob
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<y>58</y>
<width>120</width>
<height>30</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
Expand Down
2 changes: 1 addition & 1 deletion src/pvi/_format/dls.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def format_bob(self, device: Device, path: Path):
label_formatter_cls=LabelWidgetFormatter.from_template(
template,
search="Label",
property_map={"text": "text"},
property_map={"text": "text", "tooltip": "description"},
),
led_formatter_cls=PVWidgetFormatter.from_template(
template,
Expand Down
2 changes: 1 addition & 1 deletion src/pvi/_format/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def generate_component_formatters(
self.layout.label_width, self.layout.spacing
)
yield self.widget_formatter_factory.label_formatter_cls(
bounds=left, text=c.get_label()
bounds=left, text=c.get_label(), description=c.description or ""
)
else:
# Allow full width for widget
Expand Down
1 change: 1 addition & 0 deletions src/pvi/_format/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def format(self: WidgetFormatter[T]) -> List[T]:

class LabelWidgetFormatter(WidgetFormatter[T]):
text: str
description: str = ""


class PVWidgetFormatter(WidgetFormatter[T]):
Expand Down
5 changes: 4 additions & 1 deletion src/pvi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ class Named(TypedModel):
class Component(Named):
"""These make up a Device"""

label: Optional[str] = None
label: Annotated[str | None, Field(description="Label for component")] = None
description: Annotated[
str | None, Field(description="Description for label tooltip")
] = None

def get_label(self):
return self.label or to_title_case(self.name)
Expand Down
1 change: 1 addition & 0 deletions tests/format/input/signal_default_widgets.pvi.device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ children:

- type: SignalR
name: Read
description: A read-only signal
read_pv: Read

- type: SignalW
Expand Down
3 changes: 3 additions & 0 deletions tests/format/output/button.bob
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<y>30</y>
<width>120</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
Expand Down Expand Up @@ -62,6 +63,7 @@
<y>54</y>
<width>120</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="action_button" version="3.0.0">
<name>WritePV</name>
Expand Down Expand Up @@ -104,6 +106,7 @@
<y>78</y>
<width>120</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="action_button" version="3.0.0">
<name>WritePV</name>
Expand Down
1 change: 1 addition & 0 deletions tests/format/output/combo_box.bob
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<y>30</y>
<width>120</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="combo" version="2.0.0">
<name>ComboBox</name>
Expand Down
1 change: 1 addition & 0 deletions tests/format/output/device_ref.bob
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<y>30</y>
<width>120</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
Expand Down
3 changes: 3 additions & 0 deletions tests/format/output/index.bob
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<y>30</y>
<width>150</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
Expand Down Expand Up @@ -59,6 +60,7 @@
<y>55</y>
<width>150</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
Expand Down Expand Up @@ -86,6 +88,7 @@
<y>80</y>
<width>150</width>
<height>20</height>
<tooltip>$(text)</tooltip>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
Expand Down
Loading

0 comments on commit c61385b

Please sign in to comment.