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:
DefineMatrixDialogThe 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.
- class lintrans.gui.dialogs.define_new_matrix.DefineMatrixDialog[source]
Bases:
FixedSizeDialogAn 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
*argsand**kwargsare 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_wrapperand then callself.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.
- class lintrans.gui.dialogs.define_new_matrix.DefineNumericallyDialog[source]
Bases:
DefineMatrixDialogThe 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.
- class lintrans.gui.dialogs.define_new_matrix.DefineVisuallyDialog[source]
Bases:
DefineMatrixDialogThe 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
- 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
Aif 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:
FixedSizeDialogA 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
AboutDialogobject with all the label widgets.
- class lintrans.gui.dialogs.misc.DefinePolygonDialog[source]
Bases:
FixedSizeDialogThis dialog class allows the use to define a polygon with
DefinePolygonWidget.
- class lintrans.gui.dialogs.misc.FileSelectDialog[source]
Bases:
QFileDialogA subclass of
QFileDialogthat 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/testshould have.ltappended, but.lintrans/saves/testgets 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:
QDialogA 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_DeleteOnCloseattribute 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:
FixedSizeDialogA 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.
- _get_full_matrix_widget(name: str, value: Union[MatrixType, str]) QWidget[source]
Return a
QWidgetcontaining 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.
- _get_matrix_data_widget(matrix: Union[MatrixType, str]) QWidget[source]
Return a
QWidgetcontaining 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 aQWidgetcontainer with multipleQLabelobjects in it.
- class lintrans.gui.dialogs.misc.PromptUpdateDialog[source]
Bases:
FixedSizeDialogA simple dialog to ask the user if they want to upgrade their lintrans installation.
lintrans.gui.dialogs.settings module
This module provides dialogs to edit settings within the app.
- class lintrans.gui.dialogs.settings.DisplaySettingsDialog[source]
Bases:
SettingsDialogThe 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
DisplaySettingsobject to mutate
- _confirm_settings() None[source]
Build a
DisplaySettingsobject and assign it.
- _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
QKeyEventby manually activating toggling checkboxes.Qt handles these shortcuts automatically and allows the user to do
Alt + Keyto activate a simple shortcut defined with&. However, I like to be able to just hitKeyand have the shortcut activate.
- class lintrans.gui.dialogs.settings.GlobalSettingsDialog[source]
Bases:
SettingsDialogThe dialog to allow the user to edit the display settings.
- class lintrans.gui.dialogs.settings.SettingsDialog[source]
Bases:
FixedSizeDialogAn abstract superclass for other simple dialogs.
- __init__(*args, resettable: bool, **kwargs)[source]
Create the widgets and layout of the dialog, passing
*argsand**kwargsto super.
- _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.