pypeit.setup_gui.view module
The view portion of the PypeIt Setup GUI. Responsible for displaying information to the user, and forwarding user input to the controller.
- class pypeit.setup_gui.view.ConfigValuesPanel(spec_name, config, lines_to_display, parent=None)[source]
Bases:
QGroupBoxScrollable panel to display configuration values for one or more frames.
- Parameters:
- _getMinWidth()[source]
Calculate the minimum width needed to display the configuration values.
- Return type:
- class pypeit.setup_gui.view.ObsLogView(model, controller, parent=None)[source]
Bases:
TabManagerBaseTabWidget for displaying the observation log for raw data files for the same spectrograph but potentially different observing configurations.
- Parameters:
model (
pypeit.setup_gui.model.PypeItObsLogModel) – Model object for a PypeIt Setup GUI.controller (
pypeit.setup_gui.controller.PypeItObsLogController) – Controller object for the PypeIt Setup GUI.parent (QWidget) – The parent widget of the tab.
- selectedRows()[source]
Return the selected rows in the metadata table.
- Returns:
List of row indexes of the selected rows in the metadata table.
- setModel(model)[source]
Set a new model for file metadata.
- Parameters:
model (
pypeit.setup_gui.model.PypeItSetupModel) – The new metadata model
- class pypeit.setup_gui.view.PathEditor(browse_caption, parent=None)[source]
Bases:
QWidgetA custon widget that allows for entering a path. It has an editable combo box for entering file locations, a browse button to use and a file dialog to enter the file location. The history of past locations is kept in the combo box list and file dialog history.
- Parameters:
parent (QWidget) – The parent of this widget.
browse_caption (str) – The caption text to use when searching for locations, also used as place holder text when no location has been set.
- _add_path(new_path)[source]
Set the path, adding it to history and signaling listeners.
- Parameters:
new_path (str) – The new path to add.
- _new_path(new_index)[source]
Signal handler for when the combo box selects a new path.
- Parameters:
new_index – The index within the combo box that was selected.
- browse()[source]
Opens up a
FileDialogrequesting the user select a location.- Returns:
The new location, or None if Cancel was pressed.
- Return type:
- history()[source]
Returns the past history of the PathEditor widget.
- Returns:
A stringh list model with the history of the widget.
- Return type:
QStringListModel
- pathEntered
Signal sent when a path has been added.
- class pypeit.setup_gui.view.PypeItCustomEditorDelegate(parent)[source]
Bases:
QStyledItemDelegateCustom item delegate for rows in a PypeItMetadataView.
- createEditor(parent, option, index)[source]
Creates an editor widget for an item in the metadata table. This will be a PypeItEnumListEditor for the columns that use one, or the Qt default for other editable columns. Overriden from QStyledItemDelegate.
- Parameters:
parent (QWidget) – The parent widget of the new editor.
option (QtWidgets.QStyleOptionViewItem) – Additional options for the editor.
index (QModelIndex) – The index of the table cell being edited.
- editorClosed(editor, accepted)[source]
Signal handler that is notified when the PypeItEnumListEditor is closed.
- Parameters:
editor (PypeItEnumListEditor) – The editor that was closed.
accepted (bool) – True if the value was accepted, false if it was canceled.
- paint(painter, option, index)[source]
Overridden version of paint for painting items in the PypeItMetadataView.
- setEditorData(editor, index)[source]
Sets the data being edited in the editor. Overriden from QStyledItemDelegate.
- Parameters:
editor (QWidget) – The editor widget (created by createEditor)
index (QModelIndex) – The index of the item being edited.
- setModelData(editor, model, index)[source]
Sets the edited data in the model post editing. Overriden from QStyledItemDelegate.
- Parameters:
editor (QWidget) – The editor widget (created by createEditor).
model (QAbstractItemModel) – The model being edited.
index (QModelIndex) – The index of the item being edited.
- updateEditorGeometry(editor, option, index)[source]
Sets the editor’s position and size in the GUI. Overriden from QStyledItemDelegate.
- Parameters:
editor (QWidget) – The editor widget (created by crateEditor). This widgets geometry is set by this method.
model (QAbstractItemModel) – The model being edited
option (QtWidgets.QStyleOptionViewItem) – Options object containing the recommended rectangle for the editor.
index (QModelIndex) – The index of the item being edited.
- class pypeit.setup_gui.view.PypeItEnumListEditor(parent, allowed_values, index, num_lines)[source]
Bases:
QWidgetWidget for editing a enumerated list of values by checking the values on or off with a checkbox.
- Parameters:
- _choiceChecked(widget, checked)[source]
Signal handler for when one of the enumerated values is checked on or off. :type widget: QCheckBox :param widget: The widget that checked or unchecked. :type widget: QCheckBox :type checked: bool :param checked: True if the widget is checked, false if it is not. :type checked: bool
- closed
Signal sent when the user closes the editor with the OK or CANCEL button. The signal will provide the editor that was closed and a boolean that will be True if the change was accepted or False if it was canceled.
- class pypeit.setup_gui.view.PypeItFileView(model, controller)[source]
Bases:
TabManagerBaseTabWidget for displaying the information needed for one pypeit file. This includes the spectrograph, the configuration keys and values, the files that share that configuration, and the PypeIt parameters.
- Parameters:
(pypeit.setup_gui.model.PypeItFileModel) – The model representing all the information needed for a .pypeit file.
(pypeit.setup_gui.model.PypeItFileController) – The controller for managing the user’s interaction with a PypeIt file)
- selectedRows()[source]
Return the selected rows in the metadata table.
- Returns:
List of row indexes of the selected rows in the metadata table.
- property state
The state of this configuration’s model. NEW, CHANGED, or UNCHANGED.
- class pypeit.setup_gui.view.PypeItMetadataView(parent, model, controller)[source]
Bases:
QTableView- eventFilter(watched, event)[source]
Event filter that resets the mouse cursor when the mosue is over the table header
- mouseMoveEvent(event)[source]
Track which column the mouse cursor is over, and set the cursor to an I-Beam shape when over an editable column
- selectedRows()[source]
Return which rows in the PypeItMetadataPorxy model are selected.
- Returns:
list of rows indexes that are selected.
- Return type:
- selectionChanged(selected, deselected)[source]
Event handler called by Qt when a selection change. Overriden from QTableView.
- Parameters:
selected (QItemSelection) – The items that are currently selected
deselected (QItemSelection) – The items that were deselected by the change.
- selectionUpdated
Signal sent when items in the table are selected or deselected.
- class pypeit.setup_gui.view.SetupGUIMainWindow(model, controller)[source]
Bases:
QMainWindowMain window widget for the PypeIt Setup GUI
- Parameters:
model (
pypeit.setup_gui.model.SetupGUIStateModel) – The model for the PypeitSetupGUI.controller (
pypeit.setup_gui.controller.SetupGUIController) – The controller for the PypeitSetupGUI.
Populate the tool bar and menu bar by creating actions for the functionality accessible from the main window.
- create_file_tabs(pypeit_file_models)[source]
Create new tabs for new unique configurations found either by openeing a pypeit file or by reading raw data directories.
- Parameters:
pypeit_file_models (list of
pypeit.setup_gui.model.PypeItFileModel) – Models for the tabs to add.
- create_progress_dialog(op_caption, max_progress_value, cancel_func)[source]
Start displaying progress information for an operation. This uses the QProgressDialog, which will not display itself until a minimum amount of time has passed (currently 1s)
- Parameters:
op_caption (str) – The name of the operation.
max_progress_value (int) – The maximum progress value (i.e. the value when done).
cancel_func (
collections.abc.Callable) – A callable to deal with cancel being pressed in the progress dialog.
- helpURL = PyQt6.QtCore.QUrl('https://pypeit.readthedocs.io/en/stable/tutorials/setup_gui.html')
- show_operation_progress(increase, message=None)[source]
Increase the amount of progress being displayed in a progress dialog.
- update_buttons_from_model_state()[source]
Update the enabled/disabled state of buttons based on the model state.
- update_new_file_allowed()[source]
Signal handler to enable/disable adding a new file based on whether the spectrograph has been set.
- class pypeit.setup_gui.view.SpectrographValidator[source]
Bases:
QValidatorValidator to check whether a spectrograph name is valid, or potentially valid. This is used by the spectrograph combo box to allow tab completion without allowing invalid names to be entered.
- validate(str_input, int_input)[source]
Validates whether a string is a valid spectrograph name, a prefix of a valid spectrograph name, or invalid. The comparison is case insensitive because the combo box QCompleter object will convert it to the appropriate case. Overriden method from QValidator.
- Parameters:
str_input – A string input to validate.
int_input – An integer input to validate (not used).
- Returns:
Acceptable, Intermediate, or Invalid based on the input.
- Return type:
QValidator.State
- class pypeit.setup_gui.view.TabManagerBaseTab(parent=None, name='', closeable=False, state=ModelState.UNCHANGED)[source]
Bases:
QWidgetWidget that acts as a tab for
TabManagerWidget. This defines the interface needed by TabManagerWidget and provides a default implementation of it.- Parameters:
state (
pypeit.setup_gui.model.ModelState) – The state of the tab as displayed in the TabBar.
- property state
The state of the tab.
- Type:
- class pypeit.setup_gui.view.TabManagerWidget(parent, tab_position=TabPosition.South)[source]
Bases:
QTabWidgetWidget which manages tabs for the obslog and pypeit files. It extends the QTabWidget functionality by allowing tabs to be added or removed and by displaying the tab’s name with a “*” when a tab hasn’t been saved.
- Parameters:
model (
pypeit.setup_gui.model.SetupGUIStateModel) – Model object for a PypeIt Setup GUI.controller (
pypeit.setup_gui.model.SetupGUIControllerl) – Controller object for the PypeIt Setup GUI.
- _hideTabCloseButton(tab_pos, always=False)[source]
Hides the tab close button on a tab. Used for the ObsLog tab.
- addNewTab(tab)[source]
Insert a new before the “+” tab. If this is the first tab being entered (ie the + tab itself), it is appended
- Parameters:
tab (TabManagerBaseTab) – The new tab widget to add.
- Rerturns:
int: The index of the newly inserted tab.
- checkIfNewTabCurrent(index)[source]
Signal handler thast prevents the “+” tab, from being the current tab.
- checkNewTabClicked(index)[source]
Signal handler that detects a click on the “+” tab widget and sends that as a tabCreateRequest signal.
- closeTab(tab_name)[source]
Close the tab with the given name.
- Parameters:
tab_name (str) – The name of the tab to close.
- setNewTabsEnabled(enabled)[source]
Sets whether or not new tabs can be added to the tab widget. This will enable/disable the “+” tab. :type enabled: bool :param enabled: True if new tabs can be added, Fale otherwise. :type enabled: bool
- tabCreateRequest
Signal sent when the wants to add a new tab.
- updateTabText(tab_name, tab_state)[source]
Update a tab’s text when it state changes.
- Parameters:
tab_name (str) – The name of the tab to update.
tab_state (ModelState) – The model state of the data in the tab. If this is NEW or UNCHANGED, the tab’s text will be “*” + tab_name. Otherwise it will be tab_name.
- pypeit.setup_gui.view.calculateButtonMinSize(button_widget)[source]
Calculates and sets the minimum size of a budget widget
Qt has code in QCommonStyle to set this size for a button, but I kept discovering that it would report a much larger size for some reason. So this method exists to fix that.
- Parameters:
button_widget (
QPushButton) – The button to set the minimum size for. It should already have it’s text set.- Return type:
QSize- Returns:
The minimum size that was calcualted for the button