labscript_utils.qtwidgets

Helper Widgets

class labscript_utils.qtwidgets.dragdroptab.DragDropTabBar(parent, group_id)[source]

Bases: labscript_utils.qtwidgets.dragdroptab._BaseDragDropTabBar

FLUSH_GAP = 5
SCROLL_BUTTON_GAP = 2
SCROLL_BUTTON_WIDTH = 15
property drag_in_progress
property dragged_tab_index
property dragged_tab_parent
ensure_visible(index, prefer_left=True)[source]
insertion_index_at(pos)[source]

Compute at which index the tab with given upper left corner position in global coordinates should be inserted into the tabBar.

is_dragged_tab(index)[source]

Return whether the tab at the given index is currently being dragged

limbo = None
minimumSizeHint(self)QSize[source]
mouseMoveEvent(event)[source]

Update the parent of the tab to be the DragDropTabWidget under the mouse, if any, otherwise update it to the limbo object. Update the position of the tab in the widget it’s in.

mousePressEvent(event)[source]

Take note of the tab that was clicked so it can be dragged on mouseMoveEvents

mouseReleaseEvent(event)[source]

Same as mouseMove event - update the DragDropTabWidget and position of the tab to the current mouse position. Unless the mouse position is outside of any widgets at the time of mouse release, in which case move the tab to its last known parent and position.

on_scroll_button_clicked(button)[source]
paintEvent(self, QPaintEvent)[source]
paint_tab(index, painter, option)[source]
setUsesScrollButtons(self, bool)[source]
set_tab_parent(dest, index=None, pos=None)[source]

Move the tab to the given parent DragDropTabBar if it’s not already there. index=None will determined the insertion index from the given mouse position.

sizeHint(self)QSize[source]
tabAt(self, QPoint)int[source]
tabInserted(self, int)[source]
tabLayoutChange(self)[source]
tabRect(self, int)QRect[source]
tabRemoved(self, int)[source]
tab_widgets = {}
update(self)[source]

update(self, QRect) update(self, QRegion) update(self, int, int, int, int)

update_dragged_tab_animation_pos(pos)[source]
update_scroll_button_state()[source]
update_tab_index(index, pos)[source]

Check if the tab at the given index, being dragged by the mouse at the given position, needs to be moved. Move it and return the new index.

widgetAt(pos)[source]

If the given position is over a DragDropTabBar belonging to the current group, return the DragDropTabBar. If it is over a TabWidget in the same group that has no tabs, or the dragged tab as its only tab, return its DragDropTabBar. Otherwise return the limbo object.

class labscript_utils.qtwidgets.dragdroptab.DragDropTabWidget(group_id=None, accept_drops_bar_only=False)[source]

Bases: PyQt5.QtWidgets.QTabWidget

A tab widget that supports dragging and dropping of tabs between tab widgets that share a group_id. a group_id of None indicates that tab dragging is disabled.

setElideMode(self, Qt.TextElideMode)[source]
setUsesScrollButtons(self, bool)[source]
class labscript_utils.qtwidgets.dragdroptab.Tab(widget, text, data, text_color, tooltip, whats_this, button_left, button_right, icon)

Bases: tuple

property button_left

Alias for field number 6

property button_right

Alias for field number 7

property data

Alias for field number 2

property icon

Alias for field number 8

property text

Alias for field number 1

property text_color

Alias for field number 3

property tooltip

Alias for field number 4

property whats_this

Alias for field number 5

property widget

Alias for field number 0

class labscript_utils.qtwidgets.dragdroptab.TabAnimation(parent)[source]

Bases: PyQt5.QtCore.QAbstractAnimation

animate_limbo(limbo, index)[source]

If the floating tab in limbo is being sucked back into one of our tabs, then we can animate that by hiding the relevant tab rect off to the side somwhere whilst the floating tab swoops in.

duration(self)int[source]
ensure_running()[source]
on_tab_moved(source_index, dest_index)[source]
tabInserted(index)[source]
tabRemoved(index)[source]
target(i)[source]

Return the target position we are animating toward for a tab

tau = 60.0
updateCurrentTime(self, int)[source]
class labscript_utils.qtwidgets.dragdroptab.debug[source]

Bases: object

DEBUG = False
depth = 0
classmethod trace(f)[source]

decorator to print function entries and exits

class labscript_utils.qtwidgets.elide_label.ElideScrollArea(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QScrollArea

A ScrollArea for containing a label that we want to elide. The elision is attained by just letting the text we don’t want to see be scrolled off to the side with the scrollbars hidden.

event(self, QEvent)bool[source]
minimumSizeHint(self)QSize[source]
setElideMode(elideMode)[source]
setWidget(self, QWidget)[source]
sizeHint(self)QSize[source]
class labscript_utils.qtwidgets.elide_label.ElidedLabelContainer(label)[source]

Bases: PyQt5.QtWidgets.QWidget

A QWidget to contain a QLabel with a single line of (possibly rich) text that we want to elide. The elision is obtained by putting the QLabel in a QScrollArea and having the QScrollarea only show the part of the text we want to see. An extra label with the elision indication “…” is also inserted next to the QScrollArea.

elideMode()[source]
event(self, QEvent)bool[source]
minimumSizeHint(self)QSize[source]
setElideMode(elideMode)[source]
sizeHint(self)QSize[source]
update_elide_widget()[source]
labscript_utils.qtwidgets.elide_label.elide_label(label, layout, elide_mode)[source]

Take an existing label that is in a layout, and wrap it in our widgets that elide the text, and insert it back into the layout. This is a hack that allows us to elide a QLabel with a single line of (possibly rich) text, a task that seems pretty much impossible to do in any kosher way.

This function is for modifying an existing label already in a layout, but if you are programatically creating a label, then you can wrap it in ElidedLabelContainer(label) before inserting it into a layout or other container widget, which is more flexible than this function which only works if the label is in a QBoxLayout

class labscript_utils.qtwidgets.fingertab.FingerTabBarWidget(parent=None, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QTabBar

paintEvent(self, QPaintEvent)[source]
tabSizeHint(self, int)QSize[source]
class labscript_utils.qtwidgets.fingertab.FingerTabWidget(parent, *args)[source]

Bases: PyQt5.QtWidgets.QTabWidget

A QTabWidget equivalent which uses our FingerTabBarWidget

class labscript_utils.qtwidgets.headerview_with_widgets.HorizontalHeaderViewWithWidgets(model, parent=None)[source]

Bases: PyQt5.QtWidgets.QHeaderView

A QHeaderView that supports inserting arbitrary widgets into sections. Use setWidget(logical_index, widget) to set and setWidget(logical_index, None) to unset. Decorations, checkboxes or anything other than text in the headers containing widgets is unsupported, and may result in garbled output

do_update_widget_positions()[source]
eventFilter(target, event)[source]

Ensure we don’t leave the curor set as a resize handle when the mouse moves onto a child widget:

hideSection(self, int)[source]
on_columnsInserted(parent, logical_first, logical_last)[source]
on_columnsRemoved(parent, logical_first, logical_last)[source]
sectionSizeFromContents(self, int)QSize[source]
setSectionHidden(self, int, bool)[source]
setStyleSheet(self, str)[source]
setWidget(logical_index, widget=None)[source]
showEvent(self, QShowEvent)[source]
showSection(self, int)[source]
stylesheet = '\n QHeaderView::section {\n /* Will be set dynamically: */\n padding-top: %dpx;\n padding-bottom: %dpx;\n /* Required, otherwise set to zero upon setting any stylesheet at all: */\n padding-left: 4px;\n /* Required for some reason, otherwise other settings ignored: */\n color: black;\n }\n\n /* Any other style goes here: */\n %s\n '
thinspace = '\u2009'
update_indents()[source]
update_widget_positions()[source]
viewportEvent(self, QEvent)bool[source]
class labscript_utils.qtwidgets.InputPlotWindow.PlotWindow(*args, **kwargs)[source]

Bases: zprocess.process_tree.Process

run(connection_name, hardware_name, device_name)[source]

The method that gets called in the subprocess. To be overridden by subclasses

setTopLevelWindow()[source]
update_plot(new_data)[source]
class labscript_utils.qtwidgets.outputbox.OutputBox(container, scrollback_lines=1000)[source]

Bases: qtutils.outputbox.OutputBox

A subclass of qtutils.outputbox.OutputBox configured with security from labconfig.

class labscript_utils.qtwidgets.toolpalette.ToolPalette(parent, name, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QScrollArea

addWidget(widget, force_relayout=True)[source]
insertWidget(index, widget, force_relayout=True)[source]
minimumSize(self)QSize[source]
minimumSizeHint(self)QSize[source]
resizeEvent(self, QResizeEvent)[source]
sizeHint(self)QSize[source]
updateMinimumSize()[source]
class labscript_utils.qtwidgets.toolpalette.ToolPaletteGroup(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QVBoxLayout

add_to_linked_width_group(width_group_name, name)[source]
append_new_palette(name, *args, **kwargs)[source]
create_linked_width_group(width_group_name, names)[source]
get_index_from_name(name)[source]
get_name_from_index(index)[source]
get_palette(name)[source]
get_palette_by_index(index)[source]
has_palette(name)[source]
hide_palette(name)[source]
hide_palette_by_index(index)[source]
insert_new_palette(index, name, *args, **kwargs)[source]
remove(name)[source]
remove_by_index(index)[source]
remove_from_linked_width_group(width_group_name, name)[source]
reorder_palette(name, new_index)[source]
reorder_palette_by_index(old_index, new_index)[source]
show_palette(name)[source]
show_palette_by_index(index)[source]
property widths_linked

Input/Output Widgets

class labscript_utils.qtwidgets.analoginput.AnalogInput(device_name, hardware_name, connection_name='-', display_name=None, horizontal_alignment=False, parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget

get_AI()[source]
open_plot_window()[source]
set_AI(AI, notify_old_AI=True, notify_new_AI=True)[source]
set_value(value)[source]
class labscript_utils.qtwidgets.analogoutput.AnalogOutput(hardware_name, connection_name='-', display_name=None, horizontal_alignment=False, parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget

block_combobox_signals()[source]
block_spinbox_signals()[source]
connect_value_change(func)[source]
disconnect_value_change()[source]
eventFilter(self, QObject, QEvent)bool[source]
get_AO()[source]
lock(notify_ao=True)[source]
property selected_unit
set_AO(AO, notify_old_AO=True, notify_new_AO=True)[source]
set_combobox_model(model)[source]
set_limits(lower, upper)[source]
set_num_decimals(decimals)[source]
set_selected_unit(unit)[source]
set_spinbox_value(value, unit)[source]
set_step_size(step)[source]
unblock_combobox_signals()[source]
unblock_spinbox_signals()[source]
unlock(notify_ao=True)[source]
class labscript_utils.qtwidgets.analogoutput.NoStealFocusDoubleSpinBox(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QDoubleSpinBox

A QDoubleSpinBox that doesn’t steal focus as you scroll over it with a mouse wheel.

focusInEvent(self, QFocusEvent)[source]
focusOutEvent(self, QFocusEvent)[source]
wheelEvent(self, QWheelEvent)[source]
class labscript_utils.qtwidgets.ddsoutput.DDSOutput(hardware_name, connection_name='-', parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget

get_sub_widget(subchnl)[source]
hide_sub_widget(subchnl)[source]
show_sub_widget(subchnl)[source]
class labscript_utils.qtwidgets.digitaloutput.DigitalOutput(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QPushButton

eventFilter(self, QObject, QEvent)bool[source]
get_DO()[source]
lock(notify_do=True)[source]
set_DO(DO, notify_old_DO=True, notify_new_DO=True)[source]
property state
unlock(notify_do=True)[source]
class labscript_utils.qtwidgets.digitaloutput.InvertedDigitalOutput(*args, **kwargs)[source]

Bases: labscript_utils.qtwidgets.digitaloutput.DigitalOutput

property state
class labscript_utils.qtwidgets.enumoutput.EnumOutput(hardware_name, connection_name='-', display_name=None, horizontal_alignment=False, parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget

block_combobox_signals()[source]
connect_value_change(func)[source]
disconnect_value_change()[source]
eventFilter(self, QObject, QEvent)bool[source]
get_EO()[source]
lock(notify_eo=True)[source]
property selected_index
property selected_option
set_EO(EO, notify_old_EO=True, notify_new_EO=True)[source]
set_combobox_model(model)[source]
unblock_combobox_signals()[source]
unlock(notify_eo=True)[source]
class labscript_utils.qtwidgets.imageoutput.BrowseButton(image_output, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QPushButton

browse()[source]
eventFilter(self, QObject, QEvent)bool[source]
class labscript_utils.qtwidgets.imageoutput.ImageOutput(name, width, height, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget

eventFilter(self, QObject, QEvent)bool[source]
get_Image()[source]
imageUpdated
lock(notify_Image=True)[source]
set_Image(Image, notify_old_Image=True, notify_new_Image=True)[source]
unlock(notify_Image=True)[source]
property value
class labscript_utils.qtwidgets.imageoutput.ImageView(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QGraphicsView

contextMenuEvent(self, QContextMenuEvent)[source]