pypeit.setup_gui.controller module
The controller portion of the PypeIt Setup GUI. The classes in this module are responsible for acting on user input, running background tasks, and returning information to the user.
- class pypeit.setup_gui.controller.MetadataOperation(name, model)[source]
Bases:
QObject
Base class for Metadata operations that take long enough that they should take place in a background thread.
- Parameters:
model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.
- _addedMetadata(name, match)[source]
Callback used to report progress on reading files when building metadata.
- _buildingMetadata(name, match)[source]
Callback used to find the total number of files being read when building metadata.
- preRun()[source]
Perform setup required before running the operation. This involves watching the log for files being added to the metadata.
- progressMade
Signal emitted emit when progress has been made. This will be reflected in the view’s progress dialog.
- class pypeit.setup_gui.controller.MetadataPasteAction(controller, menu_text, handler, shortcut=None)[source]
Bases:
QAction
An action for pasting metadata into a PypeItMetadataModel object.
- Parameters:
controller (PypeItMetadataController) – The controller for the PypeItMetadataModel/PypeItMetadataView MVC triplet.
menu_text (str) – The text name for the menu/button that triggers the action.
handler (
collections.abc.Callable
) – The signal handler to enact the action. This receives the “triggered” event from the parent class.shortcut (QtGui.QKeySequence.StandardKey, Optional) – The keyboard shortcut to initiate the action.
- class pypeit.setup_gui.controller.MetadataReadOnlyAction(controller, menu_text, handler, shortcut=None)[source]
Bases:
QAction
An action on a PypeItMetadataModel that is read only and therefore can be performed on the ObsLog. These actions can be triggered by a button, menu, option or keyboard shortcut.
- Parameters:
controller (PypeItMetadataController) – The controller for the PypeItMetadataModel/PypeItMetadataView MVC triplet.
menu_text (str) – The text name for the menu/button that triggers the action.
handler (
collections.abc.Callable
) – The signal handler to enact the action. This receives the “triggered” event from the parent class.shortcut (QtGui.QKeySequence.StandardKey, Optional) – The keyboard shortcut to initiate the action.
- class pypeit.setup_gui.controller.MetadataWriteAction(controller, menu_text, handler, shortcut=None)[source]
Bases:
QAction
An action on a PypeItMetadataModel that can change the file metadata and therefore can only be performed on a PypeItFileModel. These actions can be triggered by a button, menu, option or keyboard shortcut.
- Parameters:
controller (PypeItMetadataController) – The controller for the PypeItMetadataModel/PypeItMetadataView MVC triplet.
menu_text (str) – The text name for the menu/button that triggers the action.
handler (
collections.abc.Callable
) – The signal handler to enact the action. This receives the “triggered” event from the parent class.shortcut (QtGui.QKeySequence.StandardKey, Optional) – The keyboard shortcut to initiate the action.
- exception pypeit.setup_gui.controller.OpCanceledError[source]
Bases:
Exception
Exception thrown when a background operation has been canceled.
- class pypeit.setup_gui.controller.OpenFileOperation(model, file)[source]
Bases:
MetadataOperation
Background operation to open a PypeIt file
- Parameters:
model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.
() (file) – The file to open.
- class pypeit.setup_gui.controller.OperationThread[source]
Bases:
QThread
Thread to run a background operation.
- _cancel_op()[source]
Cancels an in progress background operation when the user cancels the progress dialog.
- _op_complete(canceled, exc_info)[source]
Signal handler that is notified when a background operation completes.
- _op_progress(max_progress, progress_message=None)[source]
Signal handler that receives progress information from a background operation as it proceeds. It passes this to the view to increase the value showing in the progress dialog.
- completed
Signal send the operation has completed.
- startOperation(operation)[source]
Start a background operation.
- Parameters:
operation (MetadataOperation) – The MetadataOperation to start in the background thread.
- class pypeit.setup_gui.controller.PypeItFileController(model)[source]
Bases:
QObject
PypeItFileController responsible for responding to user interaction as part of a MVC triplet with PypeItFileView and PypeItFileModel
- Parameters:
main_window (
UserPromptDelegate
) – A view object that can prompt the user.model (
PypeItFileModel
) – The model for the obs log.
- class pypeit.setup_gui.controller.PypeItMetadataController(model, is_pypeit_file)[source]
Bases:
QObject
A Controller object for performing actions iniitiated by the user file metadata. Part of a MVC triplet involving PypeItMetadataModel/PypeItMetadataController/PypeItMetadataView.
- Parameters:
model (
pypeit.setup_gui.model.PypeItMetatadataModel
) – The model this controller acts with.is_pypeit_file (bool) – True if the model is for a PypeItFileModel (that is writeable model), False if it is from a PypeItObsLog model (read only)
- copy_metadata_rows() bool [source]
Copy metadata rows into the clipboard.
- Returns:
True if rows were copied, False if there were no rows to copy
- cut_metadata_rows() bool [source]
Move metadata rows from the PypeItMetadataModel to the clipboard.
- Returns:
True if rows were removed from the metadata and copied into the clipboard. False if no rows were copied or removed.
- delete_metadata_rows() bool [source]
Remove one or more selected rows from the PypeItMetadataModel.
- Returns:
True if there were metadata rows deleted, False if there weren’t any rows to delete.
- getActions(parent)[source]
Returns the actions that this controller supports.
- Returns:
List of the actions that can be performed on the PypeItMetadataModel.
- Return type:
list of QAction
- setView(view)[source]
Set the view that is responsible for displaying and receiving input for the PypeItMetadataModel.
- Parameters:
view (PypeItMetadataView) – The view.
- class pypeit.setup_gui.controller.PypeItObsLogController(model, setup_gui_controller)[source]
Bases:
QObject
PypeItObsLogController responsible for responding to user interaction as part of a MVC triplet with PypeItObsLogView and PypeItObsLogModel
- Parameters:
main_window (
UserPromptDelegate
) – A view object that can prompt the user.model (
PypeItObsLogModel
) – The model for the obs log.operation_thread (
pypeit.setup_gui.controller.SetupGUIController
) – The main Setup GUI controller.
- class pypeit.setup_gui.controller.SetupGUIController(args)[source]
Bases:
QObject
Controller for the PypeIt setup gui. It is responsible for initializing the GUI, and performing actions requested by the user.
- Parameters:
args (
argparse.Namespace
) – The non-QT command line arguments used to start the GUI.
- _save_file(file_model: PypeItFileModel, prompt_for_all: bool = False) DialogResponses [source]
Helper method to save a file prompting the user for a location to save to if needed.
- Parameters:
file_model – The file model to save.
prompt_for_all – Whether to prompt the user if they want to sue the location for subsequent files. e.g. for a save_all operation.
- Returns:
The DialogResponse from the user, or DialogResponses.ACCEPT if it wasn’t neccessary to prompt the user.
- clear()[source]
Resets the GUI to it’s initial state. Called in response to the user clicking the “Clear” button. This will prompt the user if they want to save any unsaved changes first.
- exit()[source]
Exits the GUI. Called in response to the user clicking the “Exit” button. This will prompt the user if they want to save any unsaved changes first.
- getObsLogController(model)[source]
Create the PypeItObsLogController as part of a MVC triplet.
- Parameters:
model (
PypeItObsLogModel
) – The model for the obs log.main_window (
SetupGUIMainWindow
) – The mainwindow of the setup GUI.
- getPypeItFileController(model)[source]
Create the PypeItObsLogController as part of a MVC triplet.
- Parameters:
model (
PypeItFileModel
) – The model for the obs log.
- main_window = None
- model = <pypeit.setup_gui.model.PypeItSetupGUIModel object>
- open_pypeit_file()[source]
Opens a PypeIt file. Called in response to the user the clicking the “Open” button. This method prompts the user to discard or save any current changes, prompts the user for a pypeit to open, and opens it.
- run_setup()[source]
Runs setup on the currently selected raw data directories. Called in response to the user the clicking the “Run Setup” or changing the spectrograph. This will prompt the user if they want to save any unsaved changes first and start the operation in a background thread.
- save_all()[source]
” Save all unique configurations as pypeit files. Called in response to the user clicking the “Save All” button.
- class pypeit.setup_gui.controller.SetupOperation(model)[source]
Bases:
MetadataOperation
Background operation to run pypeit setup.
- Parameters:
model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.