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: QGroupBox

Scrollable panel to display configuration values for one or more frames.

Parameters:
  • spec_name (str) – Name of spectrograph for the configuration.

  • config (dict) – The name/value pairs for the configuration keys defined by the spectrograph.

  • lines_to_display (int) – How many lines to display before scrolling.

  • parent (QWidget, Optional) – The parent widget, defaults to None.

_getMinWidth() int[source]

Calculate the minimum width needed to display the configuration values.

setNewValues(config_dict: dict) None[source]

Update the panel to display new configuration values.

Parameters:

config_dict – A dict of the new values.

class pypeit.setup_gui.view.ObsLogView(model, controller, parent=None)[source]

Bases: TabManagerBaseTab

Widget for displaying the observation log for raw data files for the same spectrograph but potentially different observing configurations.

Parameters:
_deletePaths(parent)[source]

Signal handler that removes raw data paths from the obslog

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

update_from_model()[source]

Updates the spectrograph and raw data location widgets based on model updates.

update_raw_data_paths_state()[source]

Enable/Disable the raw data paths location panel based on the model state.

class pypeit.setup_gui.view.PathEditor(browse_caption, parent=None)[source]

Bases: QWidget

A 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 FileDialog requesting the user select a location.

Returns:

The new location, or None if Cancel was pressed.

Return type:

str

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.

setHistory(history)[source]

Sets the past history of the PathEditor widget.

Parameters:

history (QStringListModel) – A string list model containing the history of the widget.

class pypeit.setup_gui.view.PypeItCustomEditorDelegate(parent)[source]

Bases: QStyledItemDelegate

Custom 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: QWidget

Widget for editing a enumerated list of values by checking the values on or off with a checkbox.

Parameters:
  • parent (QWidget) – The parent of the editor.

  • allowed_values (list of str) – The list of allowed values in the enumeration.

  • index (QModelIndex) – The index of the item being edited.

  • num_lines (int) – The number of lines to display. Any other lines will be reachable by scrolling.

_accepted(*args)[source]

Signal handler for when the “OK” button is clicked.

_canceled(*args)[source]

Signal handler for when the “Cancel” button is clicked.

_choiceChecked(widget, checked)[source]

Signal handler for when one of the enumerated values is checked on or off. :param widget: The widget that checked or unchecked. :type widget: QCheckBox :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.

selectedValues()[source]

Return what values of the enumeration have been selected.

Return (list of str): A comma seperated list of the selected values.

setSelectedValues(values)[source]

Set what values of the enumeration are selected.

Parameters:

values (list of str) – The enum values that should be selected.

class pypeit.setup_gui.view.PypeItFileView(model, controller)[source]

Bases: TabManagerBaseTab

Widget 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)

property name

The configuration name.

Type:

str

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.

Type:

pypeit.setup_gui.model.ModelState)

update_from_model()[source]

Signal handler that updates view when the underlying model changes.

class pypeit.setup_gui.view.PypeItMetadataView(parent, model, controller)[source]

Bases: QTableView

selectedRows()[source]

Return which rows in the PypeItMetadataPorxy model are selected.

Returns:

list of rows indexes that are selected.

Return type:

list

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.

setModel(model)[source]

Set the PypeItMetadataProxy model to use for the table.

Parameters:

model (pypeit.setup_gui.model.PypeItMetadataProxy) – The model for the table.

class pypeit.setup_gui.view.SetupGUIMainWindow(model, controller)[source]

Bases: QWidget

Main window widget for the PypeIt Setup GUI

Parameters:
_closeRequest(index)[source]

Called when the user tries to close a tab

_create_button_box()[source]

Create the box with action buttons.

Returns:

The widget with the action buttons for the GUI.

Return type:

QWidget

_logClosed()[source]

Signal handler that clears the log window when it closes.

_showLog()[source]

Signal handler that opens the log 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.

delete_tabs(file_list)[source]

Delete any tabs no longer in the model.

Parameters:

tab_list (list of str) – List of the configuration names removed.

operation_complete()[source]

Stop displaying progress for an operation because it has completed..

show_operation_progress(increase, message=None)[source]

Increase the amount of progress being displayed in a progress dialog.

Parameters:
  • increase (int) – How much to increase the current progress by.

  • message (str, Optional) – A message indicating what step has been performed.

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.

update_save_tab_button()[source]

Update the enabled/disabled state of the save tab button based on the current selected tab.

update_setup_button()[source]

Enable/disable the setup button based on whether a spectrograph and raw data directories have been selected.

class pypeit.setup_gui.view.SpectrographValidator[source]

Bases: QValidator

Validator 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: QWidget

Widget 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 closeable

Whether the tab can be closed.

Type:

bool

property name

The name of the tab.

Type:

str

property state

The state of the tab.

Type:

ModelState

stateChanged

Signal sent when the state of the tab changes. The the name of the tab and its state is passed.

Type:

Signal(str)

class pypeit.setup_gui.view.TabManagerWidget(parent, tab_position=TabPosition.South)[source]

Bases: QTabWidget

Widget 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.

Parameters:
  • tab_pos (int) – The index of the tab.

  • always (bool) – True if the close tab button should always be hidden. If True the tab will not reserve any space for the button to appear.

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. :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: QPushButton) QSize[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 – The button to set the minimum size for. It should already have it’s text set.

Returns:

The minimum size that was calcualted for the button

pypeit.setup_gui.view.debugSizeStuff(widget: QWidget, name='widget')[source]

Helper method for logging sizxing information about a wdiget and its layout.