Skip to content

device_panel

frog.gui.device_panel ¤

Contains a panel which enables/disables child controls when device opens/closes.

Classes¤

DevicePanel(name, title, *args, **kwargs) ¤

Bases: QGroupBox

A QGroupBox which enables/disables child controls when device opens/closes.

Create a new DevicePanel.

The controls will be disabled initially.

Parameters:

Name Type Description Default
name str

The name of the device as used in pubsub messages

required
title str

The title for the underlying QGroupBox

required
args Any

Extra arguments for the QGroupBox constructor

()
kwargs Any

Extra keyword arguments for the QGroupBox constructor

{}
Source code in frog/gui/device_panel.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def __init__(self, name: str, title: str, *args: Any, **kwargs: Any) -> None:
    """Create a new DevicePanel.

    The controls will be disabled initially.

    Args:
        name: The name of the device as used in pubsub messages
        title: The title for the underlying QGroupBox
        args: Extra arguments for the QGroupBox constructor
        kwargs: Extra keyword arguments for the QGroupBox constructor
    """
    super().__init__(title, *args, **kwargs)

    # Enable/disable controls on device connect/disconnect
    pub.subscribe(self._on_device_opened, f"device.opened.{name}")
    pub.subscribe(self._on_device_closed, f"device.closed.{name}")
Functions¤
__init_subclass__(**kwargs) ¤

Disable controls after construction.

Source code in frog/gui/device_panel.py
15
16
17
18
19
20
21
22
23
24
def __init_subclass__(cls, **kwargs):
    """Disable controls after construction."""
    super().__init_subclass__(**kwargs)

    @decorator
    def init_decorator(previous_init, self, *args, **kwargs):
        previous_init(self, *args, **kwargs)
        self.setEnabled(False)

    cls.__init__ = init_decorator(cls.__init__)