Skip to content

Commit

Permalink
Added hard-coded tooltips for input parameters section
Browse files Browse the repository at this point in the history
tooltip comments for each input is current hard-coded, need to add a docstring parser
  • Loading branch information
proy30 committed Nov 20, 2024
1 parent 7e28c8b commit 460edc8
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 65 deletions.
13 changes: 13 additions & 0 deletions src/python/impactx/dashboard/Input/generalFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,16 @@ def convert_to_correct_type(value, desired_type):
return str(value)
else:
raise ValueError("Unknown type")

# -----------------------------------------------------------------------------
# Tooltip Comments
# -----------------------------------------------------------------------------

state.particle_shape_tooltip = "Whether to calculate space charge effects."
state.kin_energy_tooltip = "Get reference particle energy (MeV)"
state.charge_qe_tooltip = (
"Get reference particle charge (positive elementary charge)"
)
state.npart_tooltip = "TBD"
state.mass_MeV_tooltip = "Get reference particle rest mass (MeV/c^2)"
state.bunch_charge_C_tooltip = "TBD"
159 changes: 94 additions & 65 deletions src/python/impactx/dashboard/Input/inputParameters/inputMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
License: BSD-3-Clause-LBNL
"""

from trame.widgets import vuetify
from trame.widgets import html, vuetify

from ...trame_setup import setup_server
from ..generalFunctions import generalFunctions
Expand Down Expand Up @@ -96,66 +96,90 @@ def card(self):
)
vuetify.VDivider()
with vuetify.VCardText():
vuetify.VCombobox(
v_model=("particle_shape",),
label="Particle Shape",
items=([1, 2, 3],),
dense=True,
)
with vuetify.VRow(classes="my-2"):
with vuetify.VCol(cols=6, classes="py-0"):
vuetify.VTextField(
label="Ref. Particle Charge",
v_model=("charge_qe",),
suffix="qe",
type="number",
with vuetify.VTooltip(bottom=True, nudge_top="10"):
with vuetify.Template(v_slot_activator="{ on, attrs }"):
vuetify.VCombobox(
v_model=("particle_shape",),
label="Particle Shape",
items=([1, 2, 3],),
dense=True,
error_messages=("charge_qe_validation",),
change=(
ctrl.on_input_change,
"[$event, 'int','charge_qe','charge_qe_validation', ['non_zero']]",
),
v_on="on",
v_bind="attrs",
)
html.Span("{{ particle_shape_tooltip }}")
with vuetify.VRow(classes="my-2"):
with vuetify.VCol(cols=6, classes="py-0"):
vuetify.VTextField(
label="Ref. Particle Mass",
v_model=("mass_MeV",),
suffix="MeV",
type="number",
dense=True,
error_messages=("mass_MeV_validation",),
change=(
ctrl.on_input_change,
"[$event, 'float','mass_MeV','mass_MeV_validation', ['positive']]",
),
)
with vuetify.VTooltip(bottom=True, nudge_top="10"):
with vuetify.Template(v_slot_activator="{ on, attrs }"):
vuetify.VTextField(
label="Ref. Particle Charge",
v_model=("charge_qe",),
suffix="qe",
type="number",
dense=True,
error_messages=("charge_qe_validation",),
change=(
ctrl.on_input_change,
"[$event, 'int','charge_qe','charge_qe_validation', ['non_zero']]",
),
v_on="on",
v_bind="attrs",
)
html.Span("{{ charge_qe_tooltip }}")
with vuetify.VCol(cols=6, classes="py-0"):
with vuetify.VTooltip(bottom=True, nudge_top="10"):
with vuetify.Template(v_slot_activator="{ on, attrs }"):
vuetify.VTextField(
label="Ref. Particle Mass",
v_model=("mass_MeV",),
suffix="MeV",
type="number",
dense=True,
error_messages=("mass_MeV_validation",),
change=(
ctrl.on_input_change,
"[$event, 'float','mass_MeV','mass_MeV_validation', ['positive']]",
),
v_on="on",
v_bind="attrs",
)
html.Span("{{ mass_MeV_tooltip }}")
with vuetify.VRow(classes="my-0"):
with vuetify.VCol(cols=12, classes="py-0"):
vuetify.VTextField(
v_model=("npart",),
label="Number of Particles",
error_messages=("npart_validation",),
change=(
ctrl.on_input_change,
"[$event, 'int','npart','npart_validation']",
),
type="number",
dense=True,
)
with vuetify.VTooltip(bottom=True, nudge_top="10"):
with vuetify.Template(v_slot_activator="{ on, attrs }"):
vuetify.VTextField(
v_model=("npart",),
label="Number of Particles",
error_messages=("npart_validation",),
change=(
ctrl.on_input_change,
"[$event, 'int','npart','npart_validation']",
),
type="number",
dense=True,
v_on="on",
v_bind="attrs",
)
html.Span("{{ npart_tooltip }}")
with vuetify.VRow(classes="my-2"):
with vuetify.VCol(cols=8, classes="py-0"):
vuetify.VTextField(
v_model=("kin_energy",),
label="Kinetic Energy",
error_messages=("kin_energy_validation",),
change=(
ctrl.on_input_change,
"[$event, 'float','kin_energy','kin_energy_validation']",
),
type="number",
dense=True,
classes="mr-2",
)
with vuetify.VTooltip(bottom=True, nudge_top="10"):
with vuetify.Template(v_slot_activator="{ on, attrs }"):
vuetify.VTextField(
v_model=("kin_energy",),
label="Kinetic Energy",
error_messages=("kin_energy_validation",),
change=(
ctrl.on_input_change,
"[$event, 'float','kin_energy','kin_energy_validation']",
),
type="number",
dense=True,
v_on="on",
v_bind="attrs",
)
html.Span("{{ kin_energy_tooltip }}")
with vuetify.VCol(cols=4, classes="py-0"):
vuetify.VSelect(
v_model=("kin_energy_unit",),
Expand All @@ -166,17 +190,22 @@ def card(self):
)
with vuetify.VRow(classes="my-2"):
with vuetify.VCol(cols=8, classes="py-0"):
vuetify.VTextField(
label="Bunch Charge",
v_model=("bunch_charge_C",),
error_messages=("bunch_charge_C_validation",),
change=(
ctrl.on_input_change,
"[$event, 'float','bunch_charge_C','bunch_charge_C_validation']",
),
type="number",
dense=True,
)
with vuetify.VTooltip(bottom=True, nudge_top="10"):
with vuetify.Template(v_slot_activator="{ on, attrs }"):
vuetify.VTextField(
label="Bunch Charge",
v_model=("bunch_charge_C",),
error_messages=("bunch_charge_C_validation",),
change=(
ctrl.on_input_change,
"[$event, 'float','bunch_charge_C','bunch_charge_C_validation']",
),
type="number",
dense=True,
v_on="on",
v_bind="attrs",
)
html.Span("{{ bunch_charge_C_tooltip }}")
with vuetify.VCol(cols=4, classes="py-0"):
vuetify.VTextField(
label="Unit",
Expand Down

0 comments on commit 460edc8

Please sign in to comment.