adsorpy.gui module¶
GUI module of adsorpy.
- class adsorpy.gui.RunSimulationInput[source]¶
Bases:
TypedDictTyped dictionary corresponding to the input of the run_simulation function.
- class adsorpy.gui.BatchSimulationInput[source]¶
Bases:
RunSimulationInputTyped dictionary with repeats argument.
- class adsorpy.gui.FilePickerWidget(parent=None, placeholder='Select a file...')[source]¶
Bases:
QWidgetWidget to help pick a file.
Initialise the file-picker widget.
- Parameters:
- _settings¶
Load the settings between sessions.
- line_edit¶
Line edit to show the path and hold the actual value.
- browse_button¶
Button to browse files.
- _fetch_setting(name, default, return_type=None)[source]¶
Fetch settings by checking if they exist followed by their value.
- Parameters:
name (
str) – The name of the setting to fetch.default (
TypeVar(T_inv,bool,int,str,float)) – The default value to return if the setting does not exist.return_type (
type[TypeVar(T_inv,bool,int,str,float)] |None) – The default return type if the setting exists. If not given, type(default) is used.
- Return type:
- Returns:
The setting value if it exists, or else the default.
- text()[source]¶
Get the text of the box being edited.
- Return type:
- Returns:
Text of the box being edited.
- staticMetaObject = PySide6.QtCore.QMetaObject("FilePickerWidget" inherits "QWidget": Methods: #33 type=Slot, signature=setText(QString), parameters=QString )¶
- adsorpy.gui.set_content(widget, content)[source]¶
Set content of widget by matched content type.
- Parameters:
widget (
QSpinBox|QDoubleSpinBox|QLineEdit|FilePickerWidget) – The widget being edited.content (
str|float|list[str]) – The content of the widget being edited.
- Raises:
ValueError – If the content does not match the widget.
- Return type:
- adsorpy.gui.extract_param_docs(func)[source]¶
Extract parameters and their types from the docstring of a function.
This function is written for reStructuredText (rst) style docstrings.
- adsorpy.gui.from_geojson_str_to_polygon(geojson_str)[source]¶
Convert from GeoJSON string to Polygon and validate geometry.
- Parameters:
geojson_str (
str) – GeoJSON string to convert to Polygon.- Return type:
- Returns:
Shapely Polygon.
- Raises:
TypeError – If the string does not generate a Polygon.
ValueError – If the generated Polygon is invalid.
GEOSException – If the string cannot be parsed as a geojson.
- adsorpy.gui.validate_polygon(pol)[source]¶
Convert the GeoJSON dict data into a real Shapely Polygon or pass the data if it is already a Polygon.
- class adsorpy.gui.SimplePolygonDict[source]¶
Bases:
TypedDictConcise representation of a GeoJSON Polygon dictionary.
- class adsorpy.gui.PydanticPolygon(shell=None, holes=None)[source]¶
Bases:
PolygonA Pydantic-native wrapper type for a Shapely Polygon.
Create a new Polygon geometry.
- class adsorpy.gui.ParamWidgets[source]¶
Bases:
TypedDictTyped dictionary for the parameter widgets.
- Variables:
radius – Radius of the molecule.
distance – Distance between the halves.
x_offset – Offset in x-direction.
y_offset – Offset in y-direction.
quad_segs – How many segments in a quarter circle.
scale – Scale of the molecule.
verts – Vertex count of the molecule.
roundedness – Roundness of the molecule.
file_name – File name of the molecule.
ignore_atoms – Ignore atoms in the molecule.
roll – Roll of the molecule.
pitch – Pitch of the molecule.
yaw – Yaw of the molecule.
z_trim – Z trim of the molecule.
reference_lattice_spacing – Reference lattice spacing of the molecule.
- radius: QDoubleSpinBox¶
- distance: QDoubleSpinBox¶
- x_offset: QDoubleSpinBox¶
- y_offset: QDoubleSpinBox¶
- scale: QDoubleSpinBox¶
- roundedness: QDoubleSpinBox¶
- file_name: FilePickerWidget¶
- roll: QDoubleSpinBox¶
- pitch: QDoubleSpinBox¶
- yaw: QDoubleSpinBox¶
- z_trim: QDoubleSpinBox¶
- reference_lattice_spacing: QDoubleSpinBox¶
- class adsorpy.gui.SymmetryWidgets[source]¶
Bases:
TypedDictTyped dictionary for the molecule symmetry widgets.
- Variables:
rot_sym – Rotation symmetry.
refl_sym – Reflection symmetry.
rot_cnt – Rotation count.
- class adsorpy.gui.MoleculeParameters[source]¶
Bases:
TypedDictMolecule parameters dataclass.
- Variables:
index – Index of the molecule parameters configuration.
label – Label of the molecule parameters configuration, guaranteed to be unique.
function_name – Function name of the molecule.
refl_sym – Reflection symmetry.
rot_sym – Rotation symmetry.
rot_cnt – Rotation count (before accounting for reflection/rotation symmetry).
polygon – 2D polygon representation of the molecule.
settings – Function input of the molecule. Defaults to an empty dictionary.
- polygon: PydanticPolygon¶
- class adsorpy.gui.SurfaceParameters[source]¶
Bases:
TypedDictSurface parameters dataclass.
- Variables:
lattice_type – Surface lattice type.
site_count – Site count of the surface.
lattice_a – Lattice spacing of the surface.
seed – RNG seed.
- class adsorpy.gui.MiscParameters[source]¶
Bases:
TypedDictMiscellaneous parameters dataclass.
- Variables:
seed – RNG seed.
timestep_limit – Maximum allowed step count of the simulation.
- class adsorpy.gui.ZoomableSvgWidget(parent=None)[source]¶
Bases:
QSvgWidgetSVG widget with zoom capabilities and an absolute floating save button.
Initialise the ZoomableSvgWidget.
- Parameters:
parent (
QSvgWidget|None) – Parent QSvgWidget.
- graphics_changed¶
- __init__(parent=None)[source]¶
Initialise the ZoomableSvgWidget.
- Parameters:
parent (
QSvgWidget|None) – Parent QSvgWidget.- Return type:
None
- resizeEvent(event)[source]¶
Handle dynamic window resizes by pinning the button to the bottom right corner.
- Parameters:
event (
QResizeEvent) – Resize event object.- Return type:
- load(contents)[source]¶
Override native load to accept raw bytes, strings, or paths while caching data.
- Parameters:
contents (
bytes|str|Path|QByteArray|memoryview[int] |bytearray) – Raw SVG byte content, string path, or Pathlib instance.- Return type:
- export_graphics()[source]¶
Handle exporting the SVG payload with native file handling and proper scaling.
- Return type:
- wheelEvent(event)[source]¶
Override scroll wheel events to support Zoom and Horizontal Pan.
- Parameters:
event (
QWheelEvent) – QWheelEvent for when scrolling occurs.- Return type:
- staticMetaObject = PySide6.QtCore.QMetaObject("ZoomableSvgWidget" inherits "QSvgWidget": Methods: #35 type=Signal, signature=graphics_changed(bool), parameters=bool )¶
- class adsorpy.gui.AutoStateMeta(name, bases, attrs)[source]¶
Bases:
ObjectType,Generic[P_mol,T_qobj]Metaclass for AppState to automatically communicate between tabs.
This metaclass scans the
fieldsclass variable and dynamically generates a private storage field (_field), a public property (field), and a Qt notification signal (fieldChanged) for each entry.- Variables:
fields – A dictionary mapping state field names to their expected types.
- Parameters:
- Return type:
AutoStateMeta[P_mol, T_qobj]
Create an AutoState class instance.
- Parameters:
- Returns:
The AutoState class instance.
- Return type:
AutoStateMeta[P_mol, T_qobj]
- fields: ClassVar[dict[str, type]] = {'coverages': 'tuple[DistArray, ...] | None', 'fraction_of_covered_area': 'tuple[DistArray, ...] | None', 'gap_size_distribution': 'DistArray | None', 'misc_params': 'MiscParameters | None', 'molecule_param_list': 'list[MoleculeParameters] | None', 'seed_input': 'QLineEdit', 'step_limit': 'QSpinBox', 'surface_params': 'SurfaceParameters | None'}¶
- class adsorpy.gui.AppState(*args, **kwargs)[source]¶
Bases:
QObjectAppState class to communicate between tabs.
This class maintains synchronised states across the user interface. Changes to any property automatically emit a corresponding
<property>Changedsignal.- Variables:
seed_input – The Qt input widget holding the seed value.
step_limit – The maximum allowable processing steps.
misc_params – Miscellaneous parameters.
molecule_param_list – Settings of the molecule(s).
surface_params – Settings of the surface.
coverages – Coverage of simulation results.
fraction_of_covered_area – Fraction of covered area of simulation results.
gap_size_distribution – Gap size distribution of simulation results.
- Parameters:
args (P_mol.args)
kwargs (P_mol.kwargs)
- Return type:
T_qobj
- property seed_input: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- property step_limit: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- property misc_params: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- property molecule_param_list: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- property surface_params: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- property coverages: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- property fraction_of_covered_area: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- property gap_size_distribution: object¶
Get the value.
- Parameters:
private_name (
str) – private name.- Returns:
the getattr() object.
- coveragesChanged¶
- fraction_of_covered_areaChanged¶
- gap_size_distributionChanged¶
- misc_paramsChanged¶
- molecule_param_listChanged¶
- seed_inputChanged¶
- staticMetaObject = PySide6.QtCore.QMetaObject("AppState" inherits "QObject": Methods: #4 type=Signal, signature=seed_inputChanged(PyObject), parameters=PyObject #5 type=Signal, signature=step_limitChanged(PyObject), parameters=PyObject #6 type=Signal, signature=misc_paramsChanged(PyObject), parameters=PyObject #7 type=Signal, signature=molecule_param_listChanged(PyObject), parameters=PyObject #8 type=Signal, signature=surface_paramsChanged(PyObject), parameters=PyObject #9 type=Signal, signature=coveragesChanged(PyObject), parameters=PyObject #10 type=Signal, signature=fraction_of_covered_areaChanged(PyObject), parameters=PyObject #11 type=Signal, signature=gap_size_distributionChanged(PyObject), parameters=PyObject )¶
- step_limitChanged¶
- surface_paramsChanged¶
- class adsorpy.gui.AdsorpyGUI[source]¶
Bases:
QMainWindowMain window application shell for the AdsorPy simulation engine framework.
Coordinates the primary window frame, top level configuration menu bars, and hooks up the shared global data state across tab layout frames.
- Variables:
window_resized – Signal of (width, height) emitted when the main application window dimensions are modified.
Initialise frame parameters, global context caches, and child windows.
This is the main window of the AdsorPy simulation application.
- __init__()[source]¶
Initialise frame parameters, global context caches, and child windows.
This is the main window of the AdsorPy simulation application.
- Return type:
None
- state¶
Shared application runtime cache synchronised across all view frames.
- _settings¶
Persistent platform configuration handle cached between user runtime sessions.
Construct the top level application drop-down menu navigation bars.
- Return type:
- _init_tabs()[source]¶
Assemble the central tab frame layout and register sub-dashboards.
- Return type:
- _load_settings_json()[source]¶
Load, validate, and version-check simulation settings profiles.
- Return type:
- _fetch_setting(name, default, return_type=None)[source]¶
Fetch settings by checking if they exist followed by their value.
- Parameters:
name (
str) – The name of the setting to fetch.default (
TypeVar(T_inv,bool,int,str,float)) – The default value to return if the setting does not exist.return_type (
type[TypeVar(T_inv,bool,int,str,float)] |None) – The default return type if the setting exists. If not given, type(default) is used.
- Return type:
- Returns:
The setting value if it exists, or else the default.
- resizeEvent(event)[source]¶
Trigger automatically whenever the window size changes.
- Parameters:
event (
QResizeEvent) – QResizeEvent, an event changing the window size.- Return type:
- staticMetaObject = PySide6.QtCore.QMetaObject("AdsorpyGUI" inherits "QMainWindow": Methods: #39 type=Signal, signature=window_resized(int,int), parameters=int, int )¶
- class adsorpy.gui.GeneralSettings(state)[source]¶
Bases:
QWidgetGeneral simulation configuration dashboard tab view.
Provides inputs for setting the execution step boundaries, absolute pseudo-random number generator seeds, and renders real-time structural vector tracking maps.
Initialise validation engines and build structural control modules.
- Parameters:
state (
AppState) – AppState object for communication between tab widgets.
- __init__(state)[source]¶
Initialise validation engines and build structural control modules.
- Parameters:
state (
AppState) – AppState object for communication between tab widgets.- Return type:
None
- _settings¶
Persistent platform configuration handle cached between user runtime sessions.
- state¶
App state object for communication between tab widgets.
- bg_signals¶
Signals for the simulation background tasks.
- input_metadata: BatchSimulationInput¶
Dict of input values, to be stored as metadata.
- _fetch_setting(name, default, return_type=None)[source]¶
Fetch settings by checking if they exist followed by their value.
- Parameters:
name (
str) – The name of the setting to fetch.default (
TypeVar(T_inv,bool,int,str,float)) – The default value to return if the setting does not exist.return_type (
type[TypeVar(T_inv,bool,int,str,float)] |None) – The default return type if the setting exists. If not given, type(default) is used.
- Return type:
- Returns:
The setting value if it exists, or else the default.
- _init_validators()[source]¶
Instantiate validation models for text constraint processing.
- Return type:
- _init_controls()[source]¶
Assemble environment settings selectors and connect state triggers.
- Return type:
- Returns:
A populated vertical layout holding runtime widgets.
- _init_feedback_textboxes()[source]¶
Provide text to show the user whether data has been loaded.
- Return type:
- _on_surface_changed(params)[source]¶
Fire instantly when surface_params changes in another tab.
- Return type:
- Parameters:
params (SurfaceParameters | None)
- _on_molecules_changed(mol_list)[source]¶
Fire instantly when molecule_param_list changes in another tab.
- Return type:
- Parameters:
mol_list (list[MoleculeParameters] | None)
- _init_svg_view()[source]¶
Construct the graphics frame and isolate structural canvas layouts.
- Return type:
- Returns:
An isolated vector viewport container canvas.
- _assemble_layout(left, center)[source]¶
Unify sub-panels inside the scalable horizontal splitter framework.
- Parameters:
left (
QWidget) – QWidget to place sub-panels inside.center (
QScrollArea) – QScrollArea to place sub-panels inside.
- Return type:
- _prepare_simulation_inputs()[source]¶
Validate UI components and format into a unified dictionary for the simulation engine.
- Return type:
- Returns:
Dict as input for run_simulation if successful, None if validation fails.
- run_batch_simulation()[source]¶
Run N parallel instances using Dask with safe child-spawned seeds.
- Return type:
- _on_simulation_complete(simulation_outputs)[source]¶
Run lightweight plotting pipeline back on the UI thread.
- _on_batch_simulation_complete(batch_outputs)[source]¶
Process multiple parallel output tuples sent back from the dask pool cluster.
- export_results()[source]¶
Export the simulation results to JSON, HDF5, Pickle, or zipped CSVs.
- Return type:
- staticMetaObject = PySide6.QtCore.QMetaObject("GeneralSettings" inherits "QWidget": )¶
- class adsorpy.gui.MoleculeGeneration(state)[source]¶
Bases:
QWidgetMolecule layout configuration dashboard tab view.
Handles dynamic generation of geometric molecule polygon shapes via reflective library lookups, updates parameters on the fly, and lists them inside a tracking layout.
Initialise settings storage engines and compile separate view columns.
- Parameters:
state (
AppState) – AppState instance for communication between tabs.
- __init__(state)[source]¶
Initialise settings storage engines and compile separate view columns.
- Parameters:
state (
AppState) – AppState instance for communication between tabs.- Return type:
None
- param_widgets: ParamWidgets¶
“Parameter widgets derived from molecule function signatures.
- opt_checkboxes: dict[str, QCheckBox]¶
“Optional checkbox widgets derived from molecule function signatures.
- _settings¶
Persistent platform configuration handle cached between user runtime sessions.
- state¶
Shared application state cache container.
- _init_data_storage()[source]¶
Initialise internal state tracking arrays and counting iterations.
- Return type:
- _build_left_panel()[source]¶
Construct the left parameters control dashboard and link active list triggers.
The left panel is populated by the parameters of a molecule selected from
adsorpy.mol_lib. The molecules are kept in a dropdown menu based on a filtered list of the molecule functions. Parameters are taken from type hints. Type hints determine whether a box is a spinbox, textbox, optional, etc.- Return type:
- Returns:
A populated structural container pane acting as the configuration panel.
- static _discover_molecule_generators()[source]¶
Isolate reflection logic filtering usable library structural definitions.
- _build_center_panel()[source]¶
Construct the viewport frame area housing the centered vector graphics.
- Return type:
- Returns:
A scroll area wrapper managing the interactive central viewport.
- _build_right_panel()[source]¶
Construct the right tracking grid columns managing existing records.
- Return type:
- Returns:
A secondary control panel listing items added to the current system context.
- _assemble_layout(left, center, right)[source]¶
Unify sub-panels inside the scalable horizontal splitter framework.
- Parameters:
left (
QWidget) – Parameter selection pane widget.center (
QScrollArea) – Scroll pane holding vector outputs.right (
QWidget) – Management column listing generated arrays.
- Return type:
- _fetch_setting(name, default, return_type=None)[source]¶
Fetch settings by checking if they exist followed by their value.
- Parameters:
name (
str) – The name of the setting to fetch.default (
TypeVar(T_inv,bool,int,str,float)) – The default value to return if the setting does not exist.return_type (
type[TypeVar(T_inv,bool,int,str,float)] |None) – The default return type if the setting exists. If not given, type(default) is used.
- Return type:
- Returns:
The setting value if it exists, or else the default.
- _delete_previous_layout()[source]¶
Recursively delete the layout of the previous molecule parameters.
- Return type:
- build_param_inputs(func_name)[source]¶
Inspect a generator function signature to build a parameter layout frame.
Clears existing child controls, parses required types from function type annotations, configures dynamic tooltip data, and maps live text update signalling pipelines.
- static _create_param_widget(annotation, default)[source]¶
Create param widget using factory strategy translating library type hints to matching user input views.
- Parameters:
- Return type:
- Returns:
A customised interactive input container widget subclass.
- Raises:
TypeError – If an unmapped or exotic data structure type is processed.
- sync_list_order(old_index, new_index)[source]¶
Take the row transformation from list A and applies it programmatically to list B.
The ReorderableListWidget allows for items to be drag/dropped. This function links the reordering.
- _build_symmetry_controls()[source]¶
Assemble the geometric shape matrix transformation property grid layouts.
- Return type:
- _build_action_buttons()[source]¶
Map active interactive preview checkboxes and form processing buttons.
- Return type:
- _update_symmetry_tooltip(is_checked)[source]¶
Update the tooltip of the rotation symmetry label and spinbox.
- launch_first_time_loader()[source]¶
Launch the first time loader from molecule_lib.
If no file path has been provided, prompt the user to add one before running the first time loader.
- Return type:
- staticMetaObject = PySide6.QtCore.QMetaObject("MoleculeGeneration" inherits "QWidget": )¶
- class adsorpy.gui.SurfaceGeneration(state)[source]¶
Bases:
QWidgetSurface generation dashboard tab view.
Provides control inputs for generating geometric lattice surfaces and displays the resulting surface within an interactive, centered viewer.
Initialise user widgets and assemble geometric layout wrappers.
- Parameters:
state (
AppState) – AppState object to share information between tabs.
- __init__(state)[source]¶
Initialise user widgets and assemble geometric layout wrappers.
- Parameters:
state (
AppState) – AppState object to share information between tabs.- Return type:
None
- state¶
Shared application state cache container.
- stored_params: SurfaceParameters | None¶
Parameters of the surface, to be communicated between tabs.
- main_splitter¶
Main splitter of the window.
- _init_validators()[source]¶
Instantiate validation models for text constraint processing.
- Return type:
- _build_left_panel()[source]¶
Construct the left controls container pane layout.
- Return type:
- Returns:
A populated structural layout container.
- staticMetaObject = PySide6.QtCore.QMetaObject("SurfaceGeneration" inherits "QWidget": )¶
- class adsorpy.gui.BackgroundTaskSignals[source]¶
Bases:
QObjectSignals for the generic background worker.
- Variables:
finished – Emits the raw output data package.
progress – Emits the current simulation progress as a percentage integer.
progress – Emits the integer percentage (0 to 100).
- staticMetaObject = PySide6.QtCore.QMetaObject("BackgroundTaskSignals" inherits "QObject": Methods: #4 type=Signal, signature=finished(PyObject), parameters=PyObject #5 type=Signal, signature=error(PyObject), parameters=PyObject #6 type=Signal, signature=progress(int), parameters=int )¶
- finished¶
- error¶
- progress¶
- class adsorpy.gui.BackgroundTask(func, *args, **kwargs)[source]¶
Bases:
QRunnable,Generic[P,R]Executes a single blocking function call in the background thread pool.
Initialise the BackgroundTask.
- Parameters:
func (
Callable[[ParamSpec(P, bound=None)],TypeVar(R)]) – Function to be executed.args (
ParamSpecArgs) – Positional arguments to be passed to the function.kwargs (
ParamSpecKwargs) – Keyword arguments to be passed to the function.
- __init__(func, *args, **kwargs)[source]¶
Initialise the BackgroundTask.
- Parameters:
func (
Callable[[ParamSpec(P, bound=None)],TypeVar(R)]) – Function to be executed.args (
ParamSpecArgs) – Positional arguments to be passed to the function.kwargs (
ParamSpecKwargs) – Keyword arguments to be passed to the function.
- Return type:
None
- class adsorpy.gui.ReorderableListWidget(parent=None)[source]¶
Bases:
QListWidgetReorderable list widget.
- Variables:
itemsMoved – Custom signal that emits (old_row_idx, new_row_idx).
- Parameters:
parent (QListWidget | None)
Initialise the ReorderableListWidget.
- Parameters:
parent (
QListWidget|None) – Parent widget.
- staticMetaObject = PySide6.QtCore.QMetaObject("ReorderableListWidget" inherits "QListWidget": Methods: #83 type=Signal, signature=itemsMoved(int,int), parameters=int, int )¶
- itemsMoved¶
- __init__(parent=None)[source]¶
Initialise the ReorderableListWidget.
- Parameters:
parent (
QListWidget|None) – Parent widget.- Return type:
None
- dropEvent(event)[source]¶
Overridden drop event method.
Define a new drop event that emits the old and the new position.
- Parameters:
event (
QDropEvent) – Event object.- Return type: