lintrans.gui.dialogs package

Module contents

This package provides separate dialogs for the main GUI.

These dialogs are for defining new matrices in different ways and editing settings.

Submodules

lintrans.gui.dialogs.define_new_matrix module

This module provides an abstract DefineMatrixDialog class and subclasses.

class lintrans.gui.dialogs.define_new_matrix.DefineAsExpressionDialog

Bases: DefineMatrixDialog

The dialog class that allows the user to define a matrix as an expression of other matrices.

__init__(*args, matrix_wrapper: MatrixWrapper, **kwargs)

Create the widgets and layout of the dialog.

Parameters

matrix_wrapper (MatrixWrapper) – The MatrixWrapper that this dialog will mutate

_confirm_matrix() None

Evaluate the matrix expression and assign its value to the name in the combo box.

_load_matrix(index: int) None

If the selected matrix is defined an expression, load that expression into the box.

_update_confirm_button() None

Enable the confirm button if the matrix expression is valid in the wrapper.

class lintrans.gui.dialogs.define_new_matrix.DefineMatrixDialog

Bases: FixedSizeDialog

An abstract superclass for definitions dialogs.

Warning

This class should never be directly instantiated, only subclassed.

__init__(*args, matrix_wrapper: MatrixWrapper, **kwargs)

Create the widgets and layout of the dialog.

Note

*args and **kwargs are passed to the super constructor (QDialog).

Parameters

matrix_wrapper (MatrixWrapper) – The MatrixWrapper that this dialog will mutate

abstract _confirm_matrix() None

Confirm the inputted matrix and assign it.

Note

When subclassing, this method should mutate self.matrix_wrapper and then call self.accept().

_load_matrix(index: int) None

Load the selected matrix into the dialog.

This method is optionally able to be overridden. If it is not overridden, then no matrix is loaded when selecting a name.

We have this method in the superclass so that we can define it as the slot for the QComboBox.activated() signal in this constructor, rather than having to define that in the constructor of every subclass.

property _selected_letter: str

Return the letter currently selected in the combo box.

abstract _update_confirm_button() None

Enable the confirm button if it should be enabled, else, disable it.

class lintrans.gui.dialogs.define_new_matrix.DefineNumericallyDialog

Bases: DefineMatrixDialog

The dialog class that allows the user to define a new matrix numerically.

__init__(*args, matrix_wrapper: MatrixWrapper, **kwargs)

Create the widgets and layout of the dialog.

Parameters

matrix_wrapper (MatrixWrapper) – The MatrixWrapper that this dialog will mutate

_confirm_matrix() None

Confirm the matrix in the boxes and assign it to the name in the combo box.

_load_matrix(index: int) None

If the selected matrix is defined, load its values into the boxes.

_update_confirm_button() None

Enable the confirm button if there are valid floats in every box.

class lintrans.gui.dialogs.define_new_matrix.DefineVisuallyDialog

Bases: DefineMatrixDialog

The dialog class that allows the user to define a matrix visually.

__init__(*args, matrix_wrapper: MatrixWrapper, display_settings: DisplaySettings, polygon_points: List[Tuple[float, float]], **kwargs)

Create the widgets and layout of the dialog.

Parameters

matrix_wrapper (MatrixWrapper) – The MatrixWrapper that this dialog will mutate

_confirm_matrix() None

Confirm the matrix that’s been defined visually.

_load_matrix(index: int) None

Show the selected matrix on the plot. If the matrix is None, show the identity.

_update_confirm_button() None

Enable the confirm button.

Note

The confirm button is always enabled in this dialog and this method is never actually used, so it’s got an empty body. It’s only here because we need to implement the abstract method.

lintrans.gui.dialogs.misc module

This module provides miscellaneous dialog classes like AboutDialog.

class lintrans.gui.dialogs.misc.AboutDialog

Bases: FixedSizeDialog

A simple dialog class to display information about the app to the user.

It only has an __init__() method because it only has label widgets, so no other methods are necessary here.

__init__(*args, **kwargs)

Create an AboutDialog object with all the label widgets.

class lintrans.gui.dialogs.misc.DefinePolygonDialog

Bases: FixedSizeDialog

This dialog class allows the use to define a polygon with DefinePolygonWidget.

__init__(*args, polygon_points: List[Tuple[float, float]], **kwargs) None

Create the dialog with the DefinePolygonWidget widget.

_confirm_polygon() None

Confirm the polygon that the user has defined.

class lintrans.gui.dialogs.misc.FileSelectDialog

Bases: QFileDialog

A subclass of QFileDialog that fixes an issue with the default suffix on UNIX platforms.

selectedFiles() List[str]

Return a list of strings containing the absolute paths of the selected files in the dialog.

There is an issue on UNIX platforms where a hidden directory will be recognised as a suffix. For example, /home/dyson/.lintrans/saves/test should have .lt appended, but .lintrans/saves/test gets recognised as the suffix, so the default suffix is not added.

To fix this, we just look at the basename and see if it needs a suffix added. We do this for every name in the list, but there should be just one name, since this class is only intended to be used for saving files. We still return the full list of filenames.

class lintrans.gui.dialogs.misc.FixedSizeDialog

Bases: QDialog

A simple superclass to create modal dialog boxes with fixed size.

We override the open() method to set the fixed size as soon as the dialog is opened modally.

__init__(*args, **kwargs) None

Set the Qt::WA_DeleteOnClose attribute to ensure deletion of dialog.

open() None

Override QDialog.open() to set the dialog to a fixed size.

class lintrans.gui.dialogs.misc.InfoPanelDialog

Bases: FixedSizeDialog

A simple dialog class to display an info panel that shows all currently defined matrices.

__init__(matrix_wrapper: MatrixWrapper, *args, **kwargs)

Create the dialog box with all the widgets needed to show the information.

_get_matrix_widget(matrix: Union[MatrixType, str]) QWidget

Return a QWidget containing the value of the matrix.

If the matrix is defined as an expression, it will be a simple QLabel. If the matrix is defined as a matrix, it will be a QWidget container with multiple QLabel objects in it.

lintrans.gui.dialogs.settings module

This module provides dialogs to edit settings within the app.

class lintrans.gui.dialogs.settings.DisplaySettingsDialog

Bases: SettingsDialog

The dialog to allow the user to edit the display settings.

__init__(*args, display_settings: DisplaySettings, **kwargs)

Create the widgets and layout of the dialog.

Parameters

display_settings (DisplaySettings) – The DisplaySettings object to mutate

_confirm_settings() None

Build a DisplaySettings object and assign it.

_load_settings() None

Load the current display settings into the widgets.

_reset_settings() None

Reset the display settings to their defaults.

_update_gui() None

Update the GUI according to other widgets in the GUI.

For example, this method updates which checkboxes are enabled based on the values of other checkboxes.

keyPressEvent(event: QKeyEvent) None

Handle a QKeyEvent by manually activating toggling checkboxes.

Qt handles these shortcuts automatically and allows the user to do Alt + Key to activate a simple shortcut defined with &. However, I like to be able to just hit Key and have the shortcut activate.

class lintrans.gui.dialogs.settings.SettingsDialog

Bases: FixedSizeDialog

An abstract superclass for other simple dialogs.

__init__(*args, resettable: bool, **kwargs)

Create the widgets and layout of the dialog, passing *args and **kwargs to super.

abstract _confirm_settings() None

Confirm the settings chosen in the dialog.

abstract _load_settings() None

Load the current settings into the widgets.

_reset_settings() None

Reset the settings.

Note

This method is empty but not abstract because not all subclasses will need to implement it.

_setup_layout(options_layout: QLayout) None

Set the layout of the settings widget.

Note

This method must be called at the end of __init__() in subclasses to setup the layout properly.