hyloa.gui.worksheet module

Code for the worksheet window, allowing data table manipulation and plotting.

class hyloa.gui.worksheet.WorksheetWindow(mdi_area, parent=None, name='worksheet', logger=None, app_instance=None)[source]

Bases: QMdiSubWindow

A worksheet subwindow for managing tabular data and plotting.

add_column()[source]

Add a new empty column to the table.

auto_expand_rows(row, col)[source]

Automatically add a new row if the user edits the last row.

Parameters:
  • row (int) – The row index that was edited.

  • col (int) – The column index that was edited.

closeEvent(event)[source]

Cleanup when the worksheet window is closed. :param event: The close event. :type event: QCloseEvent

copy_selection()[source]

Copy selected columns or selected cells to clipboard in tab-delimited format.

create_plot()[source]

Open a dialog to select columns and create a plot.

The user chooses X, Y, and optionally error bar columns.

customize_plot()[source]

Open a dialog to customize plot styles (color, marker, linestyle, label).

customize_plot_appearance()[source]

Open a dialog to customize the appearance of the plot (font sizes, minor ticks).

edit_column_name(index)[source]

Open a dialog to edit the name of the column at the given index.

Parameters:

index (int) – The index of the column to rename.

export_data()[source]

Export current worksheet data to file.

from_session_data(data_dict)[source]

Function to restore the worksheet from saved session data.

import_column_from_main()[source]

Import a column from one of the DataFrames loaded in MainApp. The worksheet will know the dataframes only if they are loaded before creating the worksheet.

load_file_into_table()[source]

Load data from a text file into the table.

The function automatically detects header rows and populates the QTableWidget with the parsed data.

on_column_header_clicked(col)[source]

Handle column header click for selection with modifiers.

Parameters:

col (int) – The index of the clicked column.

open_curve_fitting_window()[source]

Open a window to perform quick curve fitting on selected data. The user selects X and Y columns, fitting function, initial parameters, and range. The fit result is displayed and the fitted curve is plotted on the selected graph.

open_math_dialog()[source]

Open a dialog to perform arithmetic operations between columns.

open_plot_window(selections, show=True, plot_id=None, customizations=None)[source]

Open a new subwindow with a plot of the selected columns.

Parameters:
  • selections (list of dict) – List of selections, each a dict with keys: ‘x’, ‘y’, ‘x_err’, ‘y_err’ for column names.

  • show (bool, optional) – Whether to show the plot window immediately (default is True).

  • plot_id (int or None, optional) – If provided, use this as the plot ID; otherwise, auto-increment (default is

  • customizations (dict or None, optional) – Customization settings for the plot (default is None).

Returns:

The subwindow containing the plot.

Return type:

QMdiSubWindow

paste_selection()[source]

Paste tab-delimited data from clipboard into the table starting at current cell.

remove_column()[source]

Remove the currently selected column(s) from the table.

sync_to_data()[source]

Function to update dataframe storage

to_dataframe()[source]

Convert the table contents to a pandas DataFrame.

Returns:

DataFrame containing the numeric values from the table. Non-numeric values are replaced with an empty string.

Return type:

pd.DataFrame

to_session_data()[source]

Function to store all information needed to restore the worksheet session.