srsgui.ui.commandtree package

srsgui.ui.commandtree package visualizes an instance of Instrument class containing multiple components and commands using Qt Model/View programming.

The visualization helps the hierarchical structure of a command can be used more easily in the command terminal and writing the Python scripts.

srsgui.ui.commandtree.commanditem module

class srsgui.ui.commandtree.commanditem.Index

Bases: object

class srsgui.ui.commandtree.commanditem.CommandItem(parent: CommandItem | None = None)

Bases: object

Command item corresponding to a line in QTreeView. It encapsulates Component, Command, and Index class used in srsgui.Instrument class.

appendChild(item: CommandItem)

Add item as a child

child(row: int) CommandItem

Return the child of the current item from the given row

parent() CommandItem

Return the parent of the current item

childCount() int

Return the number of children of the current item

row() int

Return the row where the current item occupies in the parent

property value

Return the value of the current item

query_value()
set_value(value)

Set value to the instrument and update the value of the item

is_editable()

Return True if the item is editable

get_formatted_value()

Return formatted value of a float

construct_set_command_string(value)

Construct python command string corresponding to the item

get_name_string(item)
classmethod load(comp, parent: CommandItem | None = None) CommandItem

Create a ‘root’ CommandItem from a Component and populate its subcomponent and commands recursively.

Returns:

CommandItem

Return type:

root_item

srsgui.ui.commandtree.commandmodel module

class srsgui.ui.commandtree.commandmodel.CommandModel(parent: QObject | None = None)

Bases: QAbstractItemModel

An editable model of Command and Component

query_requested
set_requested
set_command_sent
clear()

Clear data from the model

load(document: Component)

Load model from a ComponentItem instance returned by CommandItem.loads()

Parameters:

document – Component instance

data(index: ~PySide2.QtCore.QModelIndex, role: <class 'PySide2.QtCore.Qt.ItemDataRole'>) Any

Override from QAbstractItemModel

Return data from an item according index and role

setData(index: ~PySide2.QtCore.QModelIndex, value: ~typing.Any, role: <class 'PySide2.QtCore.Qt.ItemDataRole'>)

Override from QAbstractItemModel

Set CommandItem according to index and role

Parameters:
  • index (QModelIndex)

  • value (Any)

  • role (Qt.ItemDataRole)

headerData(section: int, orientation: <class 'PySide2.QtCore.Qt.Orientation'>, role: <class 'PySide2.QtCore.Qt.ItemDataRole'>)

Override from QAbstractItemModel

it returns only data for columns (orientation = Horizontal)

index(row: int, column: int, parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>) QModelIndex

Override from QAbstractItemModel

Return index according row, column and parent

parent(index: QModelIndex) QModelIndex

Override from QAbstractItemModel

Return parent index of index

rowCount(parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)

Override from QAbstractItemModel

Return row count from parent index

columnCount(parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)

Override from QAbstractItemModel

Return column number. For the model, it always return 2 columns

flags(index: QModelIndex) ItemFlags

Override from QAbstractItemModel

Return flags of index

is_item_editable(index: QModelIndex) bool

Return True if item is editable, False otherwise

handle_command(cmd_tuple)

External command processor calls this slot once a command is processed

staticMetaObject = <PySide2.QtCore.QMetaObject object>

srsgui.ui.commandtree.commandhandler module

class srsgui.ui.commandtree.commandhandler.CommandWorker

Bases: QObject

query_processed
set_processed
handle_query(index: QModelIndex)
handle_set(cmd_tuple)
staticMetaObject = <PySide2.QtCore.QMetaObject object>
class srsgui.ui.commandtree.commandhandler.CommandHandler(parent=None)

Bases: QObject

stop()
staticMetaObject = <PySide2.QtCore.QMetaObject object>

srsgui.ui.commandtree.commanddelegate module

class srsgui.ui.commandtree.commanddelegate.CommandDelegate(parent=None)

Bases: QStyledItemDelegate

A custom delegate for editing CommandItem

createEditor(self, parent: PySide2.QtWidgets.QWidget, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) PySide2.QtWidgets.QWidget
setEditorData(self, editor: PySide2.QtWidgets.QWidget, index: PySide2.QtCore.QModelIndex) None
setModelData(self, editor: PySide2.QtWidgets.QWidget, model: PySide2.QtCore.QAbstractItemModel, index: PySide2.QtCore.QModelIndex) None
updateEditorGeometry(self, editor: PySide2.QtWidgets.QWidget, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) None
staticMetaObject = <PySide2.QtCore.QMetaObject object>

srsgui.ui.commandtree.commandspinbox module

class srsgui.ui.commandtree.commandspinbox.IntegerSpinBox

Bases: QSpinBox

Adjust step size depending on the cursor position

stepBy(self, steps: int) None
staticMetaObject = <PySide2.QtCore.QMetaObject object>
class srsgui.ui.commandtree.commandspinbox.FloatSpinBox(*args, **kwargs)

Bases: QDoubleSpinBox

Adjust step size depending on the cursor position

set_minimum_step(value)
set_significant_figures(value)
valueFromText(self, text: str) float
textFromValue(self, val: float) str
stepBy(self, steps: int) None
staticMetaObject = <PySide2.QtCore.QMetaObject object>
class srsgui.ui.commandtree.commandspinbox.RunButton(parent=None)

Bases: QWidget

pressed
staticMetaObject = <PySide2.QtCore.QMetaObject object>

srsgui.ui.commandtree.commandtreeview module

class srsgui.ui.commandtree.commandtreeview.CommandTreeView(parent=None)

Bases: QTreeView

update_item_display(parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)
connect_methods_to_buttons(parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)
staticMetaObject = <PySide2.QtCore.QMetaObject object>

srsgui.ui.commandtree.commandtreewidget module

class srsgui.ui.commandtree.commandtreewidget.CommandTreeWidget(parent=None)

Bases: QWidget, Ui_CommandTreeWidget

CommandTreeWidget is used to display an Instrument class in a tree view based on Qt Model/View architecture.

set_inst(name, inst)
on_query_only_changed(state)
on_set_only_changed(state)
on_excluded_changed(state)
on_method_changed(state)
on_raw_command_changed(state)
on_capture_clicked()
on_expand_clicked()
on_collapse_clicked()
closeEvent(self, event: PySide2.QtGui.QCloseEvent) None
staticMetaObject = <PySide2.QtCore.QMetaObject object>