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, main_controller)[source]
Bases:
QObjectBase 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.
main_controller (SetupGUIController) – The PypeIt Setup GUI’s controller object.
- _background_progress(name)[source]
Callback used to report progress on background operations and to cancel those operations.
- 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:
QActionAn 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:
QActionAn 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:
QActionAn 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:
BaseExceptionException thrown to cancel a background operation. This inherits from BaseException instead of Exception so that it isn’t caught by the python logging framework.
- class pypeit.setup_gui.controller.OpenFileOperation(model, file, main_controller)[source]
Bases:
MetadataOperationBackground operation to open a PypeIt file
- Parameters:
model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.
() (file) – The file to open.
main_controller (SetupGUIController) – The PypeIt Setup GUI’s controller object.
- class pypeit.setup_gui.controller.OperationThread(main_controller)[source]
Bases:
QThreadThread 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, main_controller)[source]
Bases:
QObjectPypeItFileController 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.main_controller (
pypeit.setup_gui.controller.SetupGUIController) – The main Setup GUI controller.
- class pypeit.setup_gui.controller.PypeItMetadataController(model, is_pypeit_file, main_controller)[source]
Bases:
QObjectA 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)
- property clipboard
- copy_metadata_rows()[source]
Copy metadata rows into the clipboard.
- Return type:
- Returns:
True if rows were copied, False if there were no rows to copy
- cut_metadata_rows()[source]
Move metadata rows from the PypeItMetadataModel to the clipboard.
- Return type:
- 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()[source]
Remove one or more selected rows from the PypeItMetadataModel.
- Return type:
- 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, main_controller)[source]
Bases:
QObjectPypeItObsLogController 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.main_controller (
pypeit.setup_gui.controller.SetupGUIController) – The main Setup GUI controller.
- class pypeit.setup_gui.controller.SetupGUIController(app, verbosity, spectrograph=None, root=None, extension='.fits')[source]
Bases:
QObjectController for the PypeIt setup gui. It is responsible for initializing the GUI, and performing actions requested by the user. On startup, it will process arguments in the same way the non-GUI version of pypeit_setup does.
- Parameters:
app (
QApplication) – QApplication for this Qt app.verbosity (
int) – Verbosity to use when logging.spectrograph (
str|None) – Optional spectrograph to use on startup.root (
list[str] |str|None) – Optional root path for raw data on startup.extension (
str|None) – Optional extension to look for when scanning raw data on startup.
- _save_file(file_model, prompt_for_all=False)[source]
Helper method to save a file prompting the user for a location to save to if needed.
- Parameters:
file_model (
PypeItFileModel) – The file model to save.prompt_for_all (
bool) – Whether to prompt the user if they want to sue the location for subsequent files. e.g. for a save_all operation.
- Return type:
- 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.
- 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, main_controller)[source]
Bases:
MetadataOperationBackground operation to run pypeit setup.
- Parameters:
model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.
main_controller (SetupGUIController) – The PypeIt Setup GUI’s controller object.