csaxs_bec.bec_widgets.widgets.xray_eye.x_ray_eye.XRayEye2DControl#

class XRayEye2DControl(parent=None, step_size: int = 100, *arg, **kwargs)[source]#

Bases: BECWidget, QWidget

Base class for all BEC widgets. This class should be used as a mixin class for all BEC widgets, e.g.:

>>> class MyWidget(BECWidget, QWidget):
>>>     def __init__(self, parent=None, client=None, config=None, gui_id=None):
>>>         super().__init__(parent=parent, client=client, config=config, gui_id=gui_id)
Parameters:
  • client (BECClient, optional) – The BEC client.

  • config (ConnectionConfig, optional) – The connection configuration.

  • gui_id (str, optional) – The GUI ID.

  • theme_update (bool, optional) – Whether to subscribe to theme updates. Defaults to False. When set to True, the widget’s apply_theme method will be called when the theme changes.

Methods

acceptDrops

accessibleDescription

accessibleIdentifier

accessibleName

actionEvent

actions

activateWindow

addAction

addActions

adjustSize

apply_config

Apply the configuration to the widget.

apply_theme

Apply the theme to the widget.

attach

autoFillBackground

backgroundRole

backingStore

baseSize

blockSignals

changeEvent

change_object_name

Change the object name of the widget.

childAt

childEvent

children

childrenRect

childrenRegion

cleanup

Cleanup the widget.

clearFocus

clearMask

close

closeEvent

Wrap the close even to ensure the rpc_register is cleaned up.

colorCount

connect

connectNotify

contentsMargins

contentsRect

contextMenuEvent

contextMenuPolicy

create

createWinId

createWindowContainer

create_busy_state_widget

Method to create a custom busy state widget to be shown in the busy overlay.

cursor

customEvent

deleteLater

depth

destroy

detach

Detach the widget from its parent dock widget (if widget is in the dock), making it a floating widget.

devType

devicePixelRatio

devicePixelRatioF

devicePixelRatioFScale

disconnect

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

dumpObjectInfo

dumpObjectTree

dynamicPropertyNames

effectiveWinId

emit

enable_controls_hor

enable_controls_ver

encodeMetricF

ensurePolished

enterEvent

event

eventFilter

export_settings

Export the settings of the widget as dict.

find

findChild

findChildren

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPolicy

focusPreviousChild

focusProxy

focusWidget

font

fontInfo

fontMetrics

foregroundRole

frameGeometry

frameSize

geometry

get_bec_shortcuts

Get BEC shortcuts for the widget.

get_config

Get the configuration of the widget.

get_help_md

Method to override in subclasses to provide help text in markdown format.

get_obj_by_id

grab

grabGesture

grabKeyboard

grabMouse

grabShortcut

graphicsEffect

graphicsProxyWidget

hasFocus

hasHeightForWidth

hasMouseTracking

hasTabletTracking

height

heightForWidth

heightMM

hide

hideEvent

inherits

initPainter

inputMethodEvent

inputMethodHints

inputMethodQuery

insertAction

insertActions

installEventFilter

internalWinId

isActiveWindow

isAncestorOf

isEnabled

isEnabledTo

isFullScreen

isHidden

isLeftToRight

isMaximized

isMinimized

isModal

isQuickItemType

isRightToLeft

isSignalConnected

isTopLevel

isVisible

isVisibleTo

isWidgetType

isWindow

isWindowModified

isWindowType

is_busy

Check if the loading overlay is enabled.

keyPressEvent

keyReleaseEvent

keyboardGrabber

killTimer

layout

layoutDirection

leaveEvent

load_config

Load the configuration of the widget from YAML.

load_settings

Load the settings of the widget from dict.

locale

logicalDpiX

logicalDpiY

lower

mapFrom

mapFromGlobal

mapFromParent

mapTo

mapToGlobal

mapToParent

mask

maximumHeight

maximumSize

maximumWidth

metaObject

metric

minimumHeight

minimumSize

minimumSizeHint

minimumWidth

mouseDoubleClickEvent

mouseGrabber

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

move

moveEvent

moveToThread

nativeEvent

nativeParentWidget

nextInFocusChain

normalGeometry

objectName

on_config_update

Update the configuration for the widget.

overrideWindowFlags

overrideWindowState

paintEngine

paintEvent

paintingActive

palette

parent

parentWidget

physicalDpiX

physicalDpiY

pos

previousInFocusChain

property

raise_

receivers

rect

redirected

releaseKeyboard

releaseMouse

releaseShortcut

remove

Cleanup the BECConnector

removeAction

removeEventFilter

render

repaint

resize

resizeEvent

restoreGeometry

saveGeometry

save_config

Save the configuration of the widget to YAML.

screen

screenshot

Take a screenshot of the dock area and save it to a file.

screenshot_bytes

Grab this widget, optionally scale to a max size, and return encoded image bytes.

screenshot_to_scilog

Take a screenshot of the widget and send it to SciLog through BEC messaging services.

scroll

sender

senderSignalIndex

setAcceptDrops

setAccessibleDescription

setAccessibleIdentifier

setAccessibleName

setAttribute

setAutoFillBackground

setBackgroundRole

setBaseSize

setContentsMargins

setContextMenuPolicy

setCursor

setDisabled

setEnabled

setFixedHeight

setFixedSize

setFixedWidth

setFocus

setFocusPolicy

setFocusProxy

setFont

setForegroundRole

setGeometry

setGraphicsEffect

setHidden

setInputMethodHints

setLayout

setLayoutDirection

setLocale

setMask

setMaximumHeight

setMaximumSize

setMaximumWidth

setMinimumHeight

setMinimumSize

setMinimumWidth

setMouseTracking

setObjectName

Set the object name of the widget.

setPalette

setParent

setProperty

setScreen

setShortcutAutoRepeat

setShortcutEnabled

setSizeIncrement

setSizePolicy

setStatusTip

setStyle

setStyleSheet

setTabOrder

setTabletTracking

setToolTip

setToolTipDuration

setUpdatesEnabled

setVisible

setWhatsThis

setWindowFilePath

setWindowFlag

setWindowFlags

setWindowIcon

setWindowIconText

setWindowModality

setWindowModified

setWindowOpacity

setWindowRole

setWindowState

setWindowTitle

set_busy

Set the busy state of the widget.

sharedPainter

show

showEvent

showFullScreen

showMaximized

showMinimized

showNormal

signalsBlocked

size

sizeHint

sizeIncrement

sizePolicy

stackUnder

startTimer

statusTip

style

styleSheet

submit_task

Submit a task to run in a separate thread.

tabletEvent

testAttribute

thread

timerEvent

toolTip

toolTipDuration

topLevelWidget

tr

underMouse

ungrabGesture

unsetCursor

unsetLayoutDirection

unsetLocale

update

updateGeometry

updateMicroFocus

update_client

Update the client and device manager from BEC and create object for BEC shortcuts.

updatesEnabled

visibleRegion

whatsThis

wheelEvent

width

widthMM

winId

window

windowFilePath

windowFlags

windowHandle

windowIcon

windowIconText

windowModality

windowOpacity

windowRole

windowState

windowTitle

windowType

x

y

Attributes

EXIT_HANDLERS

ICON_NAME

USER_ACCESS

customContextMenuRequested

destroyed

name_established

objectNameChanged

painters

parent_id

staticMetaObject

step_size

widget_removed

windowIconChanged

windowIconTextChanged

windowTitleChanged

class PaintDeviceMetric(*values)#

Bases: Enum

class RenderFlag(*values)#

Bases: Flag

apply_config(config: dict, generate_new_id: bool = True) None#

Apply the configuration to the widget.

Parameters:
  • config (dict) – Configuration settings.

  • generate_new_id (bool) – If True, generate a new GUI ID for the widget.

apply_theme(theme: str)#

Apply the theme to the widget.

Parameters:

theme (str, optional) – The theme to be applied.

change_object_name(name: str) None#

Change the object name of the widget. Unregister old name and register the new one.

Parameters:

name (str) – The new object name.

cleanup()#

Cleanup the widget.

closeEvent(event)#

Wrap the close even to ensure the rpc_register is cleaned up.

create_busy_state_widget() QWidget#

Method to create a custom busy state widget to be shown in the busy overlay. Child classes should overrid this method to provide a custom widget if desired.

Returns:

The custom busy state widget.

Return type:

QWidget

Note

The implementation here is a SpinnerWidget with a “Loading…” label. This is the default busy state widget for all BECWidgets. However, child classes with specific needs for the busy state can easily overrite this method to provide a custom widget. The signature of the method must be preserved to ensure compatibility with the busy overlay system. If the widget provides a ‘cleanup’ method, it will be called when the overlay is cleaned up.

The widget may connect to the _busy_overlay signals foreground_color_changed and scrim_color_changed to update its colors when the theme changes.

detach()#

Detach the widget from its parent dock widget (if widget is in the dock), making it a floating widget.

export_settings() dict#

Export the settings of the widget as dict.

Returns:

The exported settings of the widget.

Return type:

dict

get_bec_shortcuts()#

Get BEC shortcuts for the widget.

get_config(dict_output: bool = True) dict | BaseModel#

Get the configuration of the widget.

Parameters:

dict_output (bool) – If True, return the configuration as a dictionary. If False, return the configuration as a pydantic model.

Returns:

The configuration of the widget.

Return type:

dict | BaseModel

get_help_md() str#

Method to override in subclasses to provide help text in markdown format.

Returns:

The help text in markdown format.

Return type:

str

is_busy() bool#

Check if the loading overlay is enabled.

Returns:

True if the loading overlay is enabled, False otherwise.

Return type:

bool

load_config(path: str | None = None, gui: bool = False)#

Load the configuration of the widget from YAML.

Parameters:
  • path (str | None) – Path to the configuration file for non-GUI dialog mode.

  • gui (bool) – If True, use the GUI dialog to load the configuration file.

load_settings(settings: dict) None#

Load the settings of the widget from dict.

Parameters:

settings (dict) – The settings to load into the widget.

on_config_update(config: ConnectionConfig | dict) None#

Update the configuration for the widget.

Parameters:

config (ConnectionConfig | dict) – Configuration settings.

remove()#

Cleanup the BECConnector

save_config(path: str | None = None, gui: bool = False)#

Save the configuration of the widget to YAML.

Parameters:
  • path (str | None) – Path to save the configuration file for non-GUI dialog mode.

  • gui (bool) – If True, use the GUI dialog to save the configuration file.

screenshot(file_name: str | None = None)#

Take a screenshot of the dock area and save it to a file.

screenshot_bytes(*, max_width: int | None = None, max_height: int | None = None, fmt: str = 'PNG', quality: int = -1) QByteArray#

Grab this widget, optionally scale to a max size, and return encoded image bytes.

If max_width/max_height are omitted (the default), capture at full resolution.

Parameters:
  • max_width (int, optional) – Maximum width of the screenshot.

  • max_height (int, optional) – Maximum height of the screenshot.

  • fmt (str, optional) – Image format (e.g., “PNG”, “JPEG”).

  • quality (int, optional) – Image quality (0-100), -1 for default.

Returns:

The screenshot image bytes.

Return type:

QByteArray

screenshot_to_scilog() None#

Take a screenshot of the widget and send it to SciLog through BEC messaging services.

setObjectName(name: str) None#

Set the object name of the widget.

Parameters:

name (str) – The new object name.

set_busy(enabled: bool) None#

Set the busy state of the widget. This will show or hide the loading overlay, which will block user interaction with the widget and show the busy_state_widget if provided. Per default, the busy state widget is a spinner with “Loading…” text.

Parameters:

enabled (bool) – Whether to enable the busy state.

submit_task(fn, *args, on_complete: SafeSlot = None, **kwargs) Worker#

Submit a task to run in a separate thread. The task will run the specified function with the provided arguments and emit the completed signal when done.

Use this method if you want to wait for a task to complete without blocking the main thread.

Parameters:
  • fn – Function to run in a separate thread.

  • *args – Arguments for the function.

  • on_complete – Slot to run when the task is complete.

  • **kwargs – Keyword arguments for the function.

Returns:

The worker object that will run the task.

Return type:

worker

Examples

>>> def my_function(a, b):
>>>     print(a + b)
>>> self.submit_task(my_function, 1, 2)
>>> def my_function(a, b):
>>>     print(a + b)
>>> def on_complete():
>>>     print("Task complete")
>>> self.submit_task(my_function, 1, 2, on_complete=on_complete)
update_client(client) None#

Update the client and device manager from BEC and create object for BEC shortcuts.

Parameters:

client – BEC client.