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[source]

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)[source]

Create the widgets and layout of the dialog.

Parameters

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

_confirm_matrix() None[source]

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

_load_matrix(index: int) None[source]

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

_update_confirm_button() None[source]

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

class lintrans.gui.dialogs.define_new_matrix.DefineMatrixDialog[source]

Bases: FixedSizeDialog

An abstract superclass for definitions dialogs.

Warning

This class should never be directly instantiated, only subclassed.

__init__(*args, matrix_wrapper: MatrixWrapper, **kwargs)[source]

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[source]

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[source]

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[source]

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

class lintrans.gui.dialogs.define_new_matrix.DefineNumericallyDialog[source]

Bases: DefineMatrixDialog

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

__init__(*args, matrix_wrapper: MatrixWrapper, **kwargs)[source]

Create the widgets and layout of the dialog.

Parameters

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

_confirm_matrix() None[source]

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

_load_matrix(index: int) None[source]

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

_update_confirm_button() None[source]

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

class lintrans.gui.dialogs.define_new_matrix.DefineVisuallyDialog[source]

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]], input_vector: Tuple[float, float], **kwargs)[source]

Create the widgets and layout of the dialog.

Parameters

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

_confirm_matrix() None[source]

Confirm the matrix that’s been defined visually.

_load_matrix(index: int) None[source]

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

_update_confirm_button() None[source]

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.define_new_matrix.get_first_undefined_matrix(wrapper: MatrixWrapper) str[source]

Return the letter of the first undefined matrix in the given wrapper, or A if all matrices are defined.

lintrans.gui.dialogs.misc module

This module provides miscellaneous dialog classes like AboutDialog.

class lintrans.gui.dialogs.misc.AboutDialog[source]

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)[source]

Create an AboutDialog object with all the label widgets.

class lintrans.gui.dialogs.misc.DefinePolygonDialog[source]

Bases: FixedSizeDialog

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

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

Create the dialog with the DefinePolygonWidget widget.

_confirm_polygon() None[source]

Confirm the polygon that the user has defined.

class lintrans.gui.dialogs.misc.FileSelectDialog[source]

Bases: QFileDialog

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

selectedFiles() List[str][source]

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[source]

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[source]

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

open() None[source]

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

class lintrans.gui.dialogs.misc.InfoPanelDialog[source]

Bases: FixedSizeDialog

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

__init__(matrix_wrapper: MatrixWrapper, *args, **kwargs)[source]

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

_draw_ui() None[source]
_get_full_matrix_widget(name: str, value: Union[MatrixType, str]) QWidget[source]

Return a QWidget containing the whole matrix widget composition.

Each defined matrix will get a widget group. Each group will be a label for the name, a label for ‘=’, and a container widget to either show the matrix numerically, or to show the expression that it’s defined as.

See _get_matrix_data_widget().

_get_matrix_data_widget(matrix: Union[MatrixType, str]) QWidget[source]

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.

_undefine_matrix(name: str) None[source]

Undefine the given matrix and redraw the dialog.

class lintrans.gui.dialogs.misc.PromptUpdateDialog[source]

Bases: FixedSizeDialog

A simple dialog to ask the user if they want to upgrade their lintrans installation.

__init__(*args, new_version: str, **kwargs) None[source]

Create the dialog with all its widgets.

_save_choice_and_update(update_now: bool) None[source]

Save the user’s choice of how to update and optionally trigger an update now.

lintrans.gui.dialogs.settings module

This module provides dialogs to edit settings within the app.

class lintrans.gui.dialogs.settings.DisplaySettingsDialog[source]

Bases: SettingsDialog

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

__init__(*args, display_settings: DisplaySettings, **kwargs)[source]

Create the widgets and layout of the dialog.

Parameters

display_settings (DisplaySettings) – The DisplaySettings object to mutate

_confirm_settings() None[source]

Build a DisplaySettings object and assign it.

_load_settings() None[source]

Load the current display settings into the widgets.

_reset_settings() None[source]

Reset the display settings to their defaults.

_update_gui() None[source]

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[source]

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.GlobalSettingsDialog[source]

Bases: SettingsDialog

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

__init__(*args, **kwargs)[source]

Create the widgets and layout of the dialog.

_confirm_settings() None[source]

Set the global settings.

_load_settings() None[source]

Load the current display settings into the widgets.

_reset_settings() None[source]

Reset the internal data values to their defaults.

_update_gui() None[source]

Update the GUI according to other widgets in the GUI.

class lintrans.gui.dialogs.settings.SettingsDialog[source]

Bases: FixedSizeDialog

An abstract superclass for other simple dialogs.

__init__(*args, resettable: bool, **kwargs)[source]

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

abstract _confirm_settings() None[source]

Confirm the settings chosen in the dialog.

abstract _load_settings() None[source]

Load the current settings into the widgets.

_reset_settings() None[source]

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[source]

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.