pypeit.setup_gui.view module

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]
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]
pathEntered

Signal sent when a path has been added.

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

Bases: QStyledItemDelegate

Custom item delegate for rows in a PypeItMetadataView.

createEditor(self, parent: QWidget | None, option: QStyleOptionViewItem, index: QModelIndex) QWidget | None[source]
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(self, editor: QWidget | None, index: QModelIndex)[source]
setModelData(self, editor: QWidget | None, model: QAbstractItemModel | None, index: QModelIndex)[source]
updateEditorGeometry(self, editor: QWidget | None, option: QStyleOptionViewItem, index: QModelIndex)[source]
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. :param editor: The editor that was closed. :type editor: QWidget :param accepted: True if a change was accepted, False if it was canceled. :type accepted: bool

paint(*args, **kwargs)[source]
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]
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
property name
property state
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 by adding widgets to add and remove tabs as well as specifying the modification state 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]
checkIfNewTabCurrent(index)[source]
checkNewTabClicked(index)[source]
closeTab(tab_name)[source]
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]