Helper Components#

class ngapp.components.helper_components.Centered(*children: Component | str, **kwargs)#

Bases: Component

Create a div with centered content

Parameters:

children (Component | str)

class ngapp.components.helper_components.Col(
*children: Component | str,
weights: list[int] | list[str] | None = None,
**kwargs,
)#

Bases: Component

A container component that creates a vertical layout.

For more details on Quasar’s column grid system, see: https://quasar.dev/layout/grid/column

Parameters:
  • children (Component | str) – Variable number of child components or strings to be arranged in the column

  • weights (list[int] | list[str] | None) – Optional list of integers or strings specifying row weights/classes

  • kwargs – Additional keyword arguments passed to the parent Component

Raises:

ValueError: If the length of weights doesn’t match the number of children.

Examples:

Equal height rows (each takes available space)

>>> Col(Div("Row 1"), Div("Row 2"))

Specific row heights with weights

>>> Col(Div("Small"), Div("Large"), weights=[3, 9])
class ngapp.components.helper_components.FileName(
app=None,
ui_label='Filename',
ui_borderless=True,
compute_filename: Callable | None = None,
**kwargs,
)#

Bases: QInput

Helper to set simulation file name based on input. No input will set name to ‘Untitled’.

Args:

app: The app instance ui_label: The label for the input ui_borderless: Use ‘borderless’ design for the input

Parameters:

compute_filename (Callable | None)

class ngapp.components.helper_components.JobComponent(id: str, compute_function: Callable, *args, **kwargs)#

Bases: QBtn

A button to start and stop a job and monitor its status.

Compatibility component of apps written for compute_node; new apps use JobControl (status, queue position, progress, cancel) and RunsView. In a case session the button follows the job through its JobHandle and the case’s events, finds an unfinished job of the function again when the case is opened and stores nothing of the job in the case (job_status and progress are views of the JobHandle). Without a case store the legacy behaviour applies.

Parameters:
  • id (str) – Compoent id

  • compute_function (Callable) – Function that is called with compute_node

on_finish(handler: Callable)#

Set the function to be called with the final status when a job ended (case store only).

Parameters:

handler (Callable)

on_start(handler: Callable)#

Set the function to be called when the job is started.

Parameters:

handler (Callable)

on_stop(handler: Callable)#

Set the function to be called when the job is stopped.

Parameters:

handler (Callable)

class ngapp.components.helper_components.Label(text: str | Observable = '', **kwargs)#

Bases: Component

A text. An observable (or computed value) as text is followed: the browser updates the text in place

Parameters:

text (str | Observable)

class ngapp.components.helper_components.LoadDialog(app, *args, **kwargs)#

Bases: QDialog

A dialog to load simulations from the server

class ngapp.components.helper_components.NumberInput(*children, ui_class=['q-mx-xs'], ui_step='any', **kwargs)#

Bases: QInput

Thin wrapper for QInput with type=’number’ and model_value returning float

class ngapp.components.helper_components.Report(
app,
id,
ui_tooltip='Report',
ui_icon='mdi-file-document',
ui_flat=True,
ui_disable=True,
*args,
**kwargs,
)#

Bases: QBtn

A button that generates a pdf report from a specified format (docx, md)

create_report(
filename,
file_type: Literal['md', 'docx'],
template_path: str,
)#

Create a report in the specified format.

Args:

filename (str): The name of the report file. file_type (Literal[“md”, “docx”]): The format of the report file. template_path (str): The path to the template file. Needs to be in assets folder.

Raises:

ValueError: If the file type is not supported.

Parameters:
  • file_type (Literal['md', 'docx'])

  • template_path (str)

class ngapp.components.helper_components.Row(
*children: Component | str,
weights: list[int] | list[str] | None = None,
**kwargs,
)#

Bases: Component

A container component that arranges its children in a horizontal row layout.

For more details on Quasar’s row grid system, see: https://quasar.dev/layout/grid/row

Parameters:
  • children (Component | str) – Variable number of child components or strings to be arranged in the row

  • weights (list[int] | list[str] | None) – Optional list of integers or strings specifying column weights/classes

  • kwargs – Additional keyword arguments passed to the parent Component

Raises:

ValueError: If the length of weights doesn’t match the number of children.

Example:
>>> Row(Div("Column 1"), Div("Column 2"), weights=[6, 6])  # Equal columns
>>> Row("Auto width", "Flexible", weights=["col-md-8", "col-md-4"])
class ngapp.components.helper_components.SimulationTable(dialog=None)#

Bases: QTable

A table to display simulations from the server, if no dialog is given, the rows must be set manually

class ngapp.components.helper_components.Table(
ui_title='',
ui_rows=[],
ui_header=None,
ui_align=None,
ui_hide_bottom=True,
ui_pagination={'rowsPerPage': 0},
ui_hide_pagination=True,
ui_style='min-width:400px;margin-bottom:50px;',
**kwargs,
)#

Bases: QTable

Wrapper class around QTable that allows to pass a list of lists as rows and disables pagination by default

get_markdown()#

Get the table as markdown

property ui_rows#

Rows of data to display

class ngapp.components.helper_components.ToolBar(
app,
ui_class='bg-grey-5 text-white',
logo: str | None = None,
app_name: str | None = None,
filename: FileName | None = None,
buttons: list[Component] = [],
*args,
**kwargs,
)#

Bases: QToolbar

A toolbar with a logo, app name, filename input, new, load, save and run buttons

Parameters:
  • logo (str | None)

  • app_name (str | None)

  • filename (FileName | None)

  • buttons (list[Component])