Skip to content

Commit

Permalink
add tooltips for the transformation inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
p-j-smith committed Sep 13, 2023
1 parent 7bd28f2 commit f4ddde2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ select = [
"PD", # pandas-vet
]
ignore = [
"A002", # argument `id` is shadowing a Python builtin
"E501", # line too long
"N802", # function name lowercase
"N803", # argument name should be lowercase
Expand Down
40 changes: 33 additions & 7 deletions src/mda_tui/widgets/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@
class WidgetWithLabel(Static):
"""Add a label to a widget"""

def __init__(self, label: str, widget: Static, id: str | None = None) -> None: # noqa: A002
def __init__(
self,
label: str,
widget: Static,
id: str | None = None,
tooltip: str = "",
) -> None:
super().__init__(id=id)
self.label_text = label
self.labelled_widget = widget
super().__init__(id=id)
self.tooltip = tooltip

def compose(self) -> ComposeResult:
yield Label(self.label_text)
Expand Down Expand Up @@ -95,7 +102,15 @@ def compose(self) -> ComposeResult:
),
)

yield WidgetWithLabel(label="vector", widget=vector, id="translate_vector")
# Define tooltips
vector_tooltip = "vector by which the all atoms will be translated"

yield WidgetWithLabel(
label="vector",
widget=vector,
id="translate_vector",
tooltip=vector_tooltip,
)

@property
def vector(self):
Expand Down Expand Up @@ -169,10 +184,21 @@ def compose(self) -> ComposeResult:
)
wrap = Switch()

yield WidgetWithLabel(label="ag", widget=ag, id="center_ag")
yield WidgetWithLabel(label="center", widget=method, id="center_method")
yield WidgetWithLabel(label="point", widget=point, id="center_on")
yield WidgetWithLabel(label="wrap", widget=wrap, id="center_wrap")
# Define tooltips
ag_tooltip = "selection string for atom group to be centered on the unit cell. If empty, will center all atoms."
method_tooltip = "choose the method of centering on the selected AtomGroup."
point_tooltip = "if provided, overrides the unit cell center - the coordinates of each timestep are translated so that the center of mass/geometry of the selected AtomGroup is aligned to this position instead. Leave empty to translate to the center of the unit cell."
wrap_tooltip = "if enabled, the atoms from the selected AtomGroup will be moved to the primary unit cell before calculating the center of mass or geometry."

yield WidgetWithLabel(label="ag", widget=ag, id="center_ag", tooltip=ag_tooltip)
yield WidgetWithLabel(
label="center",
widget=method,
id="center_method",
tooltip=method_tooltip,
)
yield WidgetWithLabel(label="point", widget=point, id="center_on", tooltip=point_tooltip)
yield WidgetWithLabel(label="wrap", widget=wrap, id="center_wrap", tooltip=wrap_tooltip)

@property
def selection(self):
Expand Down

0 comments on commit f4ddde2

Please sign in to comment.