# Widget classes

class pymeasure.display.widgets.browser_widget.BrowserWidget(*args, parent=None)

  Bases: `QWidget`

  Widget wrapper for `Browser` class

class pymeasure.display.widgets.directory_widget.DirectoryLineEdit(parent=None)

  Bases: `QLineEdit`

  Widget that allows to choose a directory path. A completer is implemented for quick completion. A browse button is available.

class pymeasure.display.widgets.estimator_widget.EstimatorThread(get_estimates_callable)

  Bases: `StoppableQThread`

  run(self)

class pymeasure.display.widgets.estimator_widget.EstimatorWidget(parent=None)

  Bases: `QWidget`

  Widget that allows to display up-front estimates of the measurement procedure.

  This widget relies on a get_estimates method of the `Procedure` class. get_estimates is expected to return a list of tuples, where each tuple contains two strings: a label and the estimate.

  If the `SequencerWidget` is also used, it is possible to ask for the current sequencer or its length by asking for two keyword arguments in the Implementation of the get_estimates function: sequence and sequence_length, respectively.

  check_get_estimates_signature()

    Method that checks the signature of the get_estimates function. It checks which input arguments are allowed and, if the output is correct for the EstimatorWidget, stores the number of estimates.

  display_estimates(estimates)

    Method that updates the shown estimates for the given set of estimates.

    Parameters:

      estimates – The set of estimates to be shown in the form of a list of tuples of (2) strings

  get_estimates()

    Method that makes a procedure with the currently entered parameters and returns the estimates for these parameters.

  update_estimates()

    Method that gets and displays the estimates. Implemented for connecting to the ‘update’-button.

class pymeasure.display.widgets.fileinput_widget.FileInputWidget(parent=None)

  Bases: `QWidget`

  Widget for controlling where the data of an experiment will be stored.

  The widget consists of a field for the filename (`FilenameLineEdit`), a field for the directory (`DirectoryLineEdit`), and a checkbox to control whether the measurement is stored.

  property directory

    String controlling the directory where the file will be stored.

  property extensions

    List of extensions that are recognized by the widget.

    The first value of this list will be used as default value in case no extension is provided in the filename input field.

  property filename

    String controlling the filename that is shown in the filename input field.

  property filename_base

    String containing the base of the filename with which the file will be stored. Can only be read.

  property filename_extension

    String containing the file extension with which the file will be stored.

    Can only be read.

  property filename_fixed

    Boolean controlling whether the filename input field is frozen. If True, the filename field will be visible but disabled (i.e., grayed out).

  property store_measurement

    Boolean controlling whether the measurement will be stored.

class pymeasure.display.widgets.filename_widget.FilenameLineEdit(procedure_class, parent=None)

  Bases: `QLineEdit`

  Widget that allows to choose a filename. A completer is implemented for quick completion of placeholders

class pymeasure.display.widgets.filename_widget.FilenameValidator(placeholders, parent)

  Bases: `QValidator`

  fixup(self, a0: str | None) → str
  validate(self, a0: str | None, a1: int)

class pymeasure.display.widgets.filename_widget.PlaceholderCompleter(placeholders)

  Bases: `QCompleter`

  splitPath(self, path: str | None) → List[str]

class pymeasure.display.widgets.image_frame.ImageFrame(x_axis, y_axis, z_axis=None, refresh_time=0.2, check_status=True, parent=None)

  Bases: `PlotFrame`

  Extends `PlotFrame` to plot also axis Z using colors

  ResultsClass

    alias of `ResultsImage`

class pymeasure.display.widgets.image_widget.ImageWidget(name, columns, x_axis, y_axis, z_axis=None, refresh_time=0.2, check_status=True, parent=None)

  Bases: `TabWidget`, `QWidget`

  Extends the `ImageFrame` to allow different columns of the data to be dynamically chosen

  load(curve)

    Add curve to widget

  new_curve(results, color=<PyQt6.QtGui.QColor object>, **kwargs)

    Creates a new image

  remove(curve)

    Remove curve from widget

  sizeHint(self) → QSize

class pymeasure.display.widgets.inputs_widget.InputsWidget(procedure_class, inputs=(), parent=None, hide_groups=True, inputs_in_scrollarea=False)

  Bases: `QWidget`

  Widget wrapper for various Inputs classes

  get_procedure()

    Returns the current procedure

class pymeasure.display.widgets.log_widget.HTMLFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)

  Bases: `Formatter`

  format(record)

    Format the specified record as text.

    The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class pymeasure.display.widgets.log_widget.LogWidget(name, parent=None, fmt=None, datefmt=None)

  Bases: `TabWidget`, `QWidget`

  Widget to display logging information in GUI

  It is recommended to include this widget in all subclasses of `ManagedWindowBase`

class pymeasure.display.widgets.plot_frame.PlotFrame(x_axis=None, y_axis=None, refresh_time=0.2, check_status=True, parent=None)

  Bases: `QFrame`

  Combines a PyQtGraph Plot with Crosshairs. Refreshes the plot based on the refresh_time, and allows the axes to be changed on the fly, which updates the plotted data

  ResultsClass

    alias of `ResultsCurve`

  parse_axis(axis)

    Returns the units of an axis by searching the string

class pymeasure.display.widgets.plot_widget.PlotWidget(name, columns, x_axis=None, y_axis=None, refresh_time=0.2, check_status=True, linewidth=1, parent=None)

  Bases: `TabWidget`, `QWidget`

  Extends `PlotFrame` to allow different columns of the data to be dynamically chosen

  clear_widget()

    Clear widget content

    Behaviour is widget specific and it is currently used in preview mode

  load(curve)

    Add curve to widget

  new_curve(results, color=<PyQt6.QtGui.QColor object>, **kwargs)

    Create a new curve

  preview_widget(parent=None)

    Return a widget suitable for preview during loading

  remove(curve)

    Remove curve from widget

  set_color(curve, color)

    Change the color of the pen of the curve

  sizeHint(self) → QSize

class pymeasure.display.widgets.results_dialog.ResultsDialog(procedure_class, widget_list=(), parent=None)

  Bases: `QFileDialog`

  Widget that displays a dialog box for loading a past experiment run. It shows a preview of curves from the results file when selected in the dialog box.

  This widget used by the open_experiment method in `ManagedWindowBase` class

class pymeasure.display.widgets.sequencer_widget.ComboBoxDelegate(owner, choices)

  Bases: `QStyledItemDelegate`

  createEditor(self, parent: QWidget | None, option: QStyleOptionViewItem, index: QModelIndex) → QWidget | None
  setEditorData(self, editor: QWidget | None, index: QModelIndex)
  setModelData(self, editor: QWidget | None, model: QAbstractItemModel | None, index: QModelIndex)
  updateEditorGeometry(self, editor: QWidget | None, option: QStyleOptionViewItem, index: QModelIndex)

class pymeasure.display.widgets.sequencer_widget.ExpressionValidator

  Bases: `QValidator`

  validate(self, a0: str | None, a1: int)

class pymeasure.display.widgets.sequencer_widget.LineEditDelegate

  Bases: `QStyledItemDelegate`

  createEditor(self, parent: QWidget | None, option: QStyleOptionViewItem, index: QModelIndex) → QWidget | None
  setEditorData(self, editor: QWidget | None, index: QModelIndex)
  setModelData(self, editor: QWidget | None, model: QAbstractItemModel | None, index: QModelIndex)
  updateEditorGeometry(self, editor: QWidget | None, option: QStyleOptionViewItem, index: QModelIndex)

class pymeasure.display.widgets.sequencer_widget.SequenceDialog(save=False, parent=None)

  Bases: `QFileDialog`

  Widget that displays a dialog box for loading or saving a sequence tree.

  It also shows a preview of sequence tree in the dialog box

  Parameters:

    save – True if we are saving a file. Default False.

class pymeasure.display.widgets.sequencer_widget.SequencerTreeModel(data, header=('Level', 'Parameter', 'Sequence'), parent=None)

  Bases: `QAbstractItemModel`

  Model for sequencer data

  Parameters:

    - header – List of string representing header data

    - data – data associated with the model

    - parent – A QWidget that QT will give ownership of this Widget to.

  add_node(parameter, parent=None)

    Add a row in the sequencer

  columnCount(parent)

    Return the number of columns in the model header.

    The parent parameter exists only to support the signature of QAbstractItemModel.

  data(index, role)

    Return the data to display for the given index and the given role.

    This method should not be called directly. This method is called implicitly by the QTreeView that is displaying us, as the way of finding out what to display where.

  flags(index)

    Set the flags for the item at the given QModelIndex.

    Here, we just set all indexes to enabled, and selectable.

  headerData(section, orientation, role)

    Return the header data for the given section, orientation and role.

    This method should not be called directly. This method is called implicitly by the QTreeView that is displaying us, as the way of finding out what to display where.

  index(row, col, parent)

    Return a QModelIndex instance pointing the row and column underneath the parent given. This method should not be called directly. This method is called implicitly by the QTreeView that is displaying us, as the way of finding out what to display where.

  parent(index=None)

    Return the index of the parent of a given index. If index is not supplied, return an invalid QModelIndex.

    Parameters:

      index – QModelIndex optional.

    Returns:

  remove_node(index)

    Remove a row in the sequencer

  rowCount(parent)

    Return the number of children of a given parent.

    > If an invalid QModelIndex is supplied, return the number of children under the root.

    Parameters:

      parent – QModelIndex

  setData(self, index: QModelIndex, value: Any, role: int = Qt.EditRole) → bool
  visit_tree(parent)

    Return a generator to enumerate all the nodes in the tree

class pymeasure.display.widgets.sequencer_widget.SequencerTreeView(parent=None)

  Bases: `QTreeView`

  setModel(self, model: QAbstractItemModel | None)

class pymeasure.display.widgets.sequencer_widget.SequencerWidget(inputs=None, sequence_file=None, parent=None)

  Bases: `QWidget`

  Widget that allows to generate a sequence of measurements

  It allows sweeping parameters and moreover, one can write a simple text file to easily load a sequence. Sequences can also be saved

  Currently requires a queue function of the `ManagedWindow` to have a “procedure” argument.

  Parameters:

    inputs – List of strings representing the parameters name

  load_sequence(*, filename=None)

    Load a sequence from a .txt file.

    Parameters:

      filename – Filename (string) of the to-be-loaded file.

  queue_sequence()

    Obtain a list of parameters from the sequence tree, enter these into procedures, and queue these procedures.

class pymeasure.display.widgets.tab_widget.TabWidget(name, *args, **kwargs)

  Bases: `object`

  Utility class to define default implementation for some basic methods.

  When defining a widget to be used in subclasses of `ManagedWindowBase`, users should inherit from this class and provide an implementation of these methods

  clear_widget()

    Clear widget content

    Behaviour is widget specific and it is currently used in preview mode

  load(curve)

    Add curve to widget

  new_curve(*args, **kwargs)

    Create a new curve

  preview_widget(parent=None)

    Return a Qt widget suitable for preview during loading

    See also `ResultsDialog` If the object returned is not None, then it should have also an attribute name.

  remove(curve)

    Remove curve from widget

  set_color(curve, color)

    Set color for widget

class pymeasure.display.widgets.dock_widget.DockWidget(name, procedure_class, x_axis_labels=None, y_axis_labels=None, linewidth=1, layout_path='./', layout_filename='', parent=None)

  Bases: `TabWidget`, `QWidget`

  Widget that contains a DockArea with a number of Docks as determined by the length of the longest x_axis_labels or y_axis_labels list.

  Parameters:

    - name – Name for the TabWidget

    - procedure_class – procedure class describing the experiment (see `Procedure`)

    - x_axis_labels – List of data column(s) for the x-axis of the plot. If the list is shorter than y_axis_labels the last item in the list to match y_axis_labels length.

    - y_axis_labels – List of data column(s) for the y-axis of the plot. If the list is shorter than x_axis_labels the last item in the list to match x_axis_labels length.

    - linewidth – line width for plots in `PlotWidget`

    - layout_path – Directory path to save dock layout state. Default is ‘./’

    - layout_filename – Optional filename for dock layout file. Default: current procedure class + “_dock_layout.json”

    - parent – Passed on to QtWidgets.QWidget. Default is None

  contextMenuEvent(self, a0: QContextMenuEvent | None)
  new_curve(results, color=<PyQt6.QtGui.QColor object>, **kwargs)

    Create a new curve

  save_dock_layout()

    Save the current layout of the docks and the plot settings. When running the GUI you can access this function by right-clicking in the widget area to bring up the context menu and selecting “Save Dock Layout”

class pymeasure.display.widgets.table_widget.PandasModelBase(column_index=None, results_list=[], parent=None)

  Bases: `QAbstractTableModel`

  This class provided a model to manage multiple panda dataframes and display them as a single table.

  The multiple pandas dataframes are provided as ResultTable class instances and all of them share the same number of columns.

  There are some assumptions: - Series in the dataframe are identical, we call this number k - Series length can be different, we call this number l(x), where x=1..n

  The data can be presented as follow: - By column: each series in a separate column, in this case table shape will be: (k*n) x (max(l(x) x=1..n) - By row: column fixed to the number of series, in this case table shape will be: k x (sum of l(x) x=1..n)

  columnCount(self, parent: QModelIndex = QModelIndex()) → int
  data(self, index: QModelIndex, role: int = Qt.DisplayRole) → Any
  headerData(section, orientation, role)

    Return header information

    Override method from QAbstractTableModel

  pandas_column_count()

    Return total column count of the panda dataframes

    The value depends on the geometry selected to display dataframes

  pandas_row_count()

    Return total row count of the panda dataframes

    The value depends on the geometry selected to display dataframes

  rowCount(self, parent: QModelIndex = QModelIndex()) → int
  translate_to_global(results, row, col)

    Translate from single results coordinates to full table coordinates

  translate_to_local(row, col)

    Translate from full table coordinate to single results coordinates

class pymeasure.display.widgets.table_widget.PandasModelByColumn(column_index=None, results_list=[], parent=None)

  Bases: `PandasModelBase`

  pandas_column_count()

    Return total column count of the panda dataframes

    The value depends on the geometry selected to display dataframes

  pandas_row_count()

    Return total row count of the panda dataframes

    The value depends on the geometry selected to display dataframes

  translate_to_global(results, row, col)

    Translate from single results coordinates to full table coordinates

  translate_to_local(row, col)

    Translate from full table coordinate to single results coordinates

class pymeasure.display.widgets.table_widget.PandasModelByRow(column_index=None, results_list=[], parent=None)

  Bases: `PandasModelBase`

  pandas_column_count()

    Return total column count of the panda dataframes

    The value depends on the geometry selected to display dataframes

  pandas_row_count()

    Return total row count of the panda dataframes

    The value depends on the geometry selected to display dataframes

  translate_to_global(results, row, col)

    Translate from single results coordinates to full table coordinates

  translate_to_local(row, col)

    Translate from full table coordinate to single results coordinates

class pymeasure.display.widgets.table_widget.ResultsTable(results, color, column_index=None, force_reload=False, wdg=None, **kwargs)

  Bases: `QObject`

  Class representing a panda dataframe

class pymeasure.display.widgets.table_widget.Table(refresh_time=0.2, check_status=True, force_reload=False, layout_class=<class 'pymeasure.display.widgets.table_widget.PandasModelByColumn'>, column_index=None, float_digits=6, parent=None)

  Bases: `QTableView`

  Table format view of `Experiment` objects

  setModel(self, model: QAbstractItemModel | None)
  set_model(model_class)

    Replace model with new instance of model_class

class pymeasure.display.widgets.table_widget.TableWidget(name, columns, by_column=True, column_index=None, refresh_time=0.2, float_digits=6, check_status=True, parent=None)

  Bases: `TabWidget`, `QWidget`

  Widget to display experiment data in a tabular format

  clear_widget()

    Clear widget content

    Behaviour is widget specific and it is currently used in preview mode

  load(table)

    Add curve to widget

  new_curve(results, color=<PyQt6.QtGui.QColor object>, **kwargs)

    Create a new curve

  preview_widget(parent=None)

    Return a widget suitable for preview during loading

  remove(table)

    Remove curve from widget

  set_color(table, color)

    Change the color of the pen of the curve