mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix(cleanup): cleanup added to device_input widgets and scan_control
This commit is contained in:
@ -17,6 +17,7 @@ class Widgets(str, enum.Enum):
|
|||||||
BECDock = "BECDock"
|
BECDock = "BECDock"
|
||||||
BECDockArea = "BECDockArea"
|
BECDockArea = "BECDockArea"
|
||||||
BECFigure = "BECFigure"
|
BECFigure = "BECFigure"
|
||||||
|
ScanControl = "ScanControl"
|
||||||
SpiralProgressBar = "SpiralProgressBar"
|
SpiralProgressBar = "SpiralProgressBar"
|
||||||
TextBox = "TextBox"
|
TextBox = "TextBox"
|
||||||
VSCodeEditor = "VSCodeEditor"
|
VSCodeEditor = "VSCodeEditor"
|
||||||
@ -1823,6 +1824,24 @@ class Ring(RPCBase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ScanControl(RPCBase):
|
||||||
|
@property
|
||||||
|
@rpc_call
|
||||||
|
def config_dict(self) -> "dict":
|
||||||
|
"""
|
||||||
|
Get the configuration of the widget.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: The configuration of the widget.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@rpc_call
|
||||||
|
def get_all_rpc(self) -> "dict":
|
||||||
|
"""
|
||||||
|
Get all registered RPC objects.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class SpiralProgressBar(RPCBase):
|
class SpiralProgressBar(RPCBase):
|
||||||
@rpc_call
|
@rpc_call
|
||||||
def get_all_rpc(self) -> "dict":
|
def get_all_rpc(self) -> "dict":
|
||||||
|
@ -82,3 +82,11 @@ class DeviceComboBox(DeviceInputBase, QComboBox):
|
|||||||
if device_obj is None:
|
if device_obj is None:
|
||||||
raise ValueError(f"Device {device_name} is not found.")
|
raise ValueError(f"Device {device_name} is not found.")
|
||||||
return device_obj
|
return device_obj
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
"""Cleanup the widget."""
|
||||||
|
super().cleanup()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
super().cleanup()
|
||||||
|
QComboBox().closeEvent(event)
|
@ -118,3 +118,6 @@ class DeviceInputBase(BECConnector):
|
|||||||
"""
|
"""
|
||||||
if device not in self.get_device_list(self.config.device_filter):
|
if device not in self.get_device_list(self.config.device_filter):
|
||||||
raise ValueError(f"Device {device} is not valid.")
|
raise ValueError(f"Device {device} is not valid.")
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
super().cleanup()
|
||||||
|
@ -94,3 +94,11 @@ class DeviceLineEdit(DeviceInputBase, QLineEdit):
|
|||||||
if device_obj is None:
|
if device_obj is None:
|
||||||
raise ValueError(f"Device {device_name} is not found.")
|
raise ValueError(f"Device {device_name} is not found.")
|
||||||
return device_obj
|
return device_obj
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
"""Cleanup the widget."""
|
||||||
|
super().cleanup()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
super().cleanup()
|
||||||
|
QLineEdit().closeEvent(event)
|
@ -184,8 +184,21 @@ class ScanControl(BECConnector, QWidget):
|
|||||||
if callable(scan_function):
|
if callable(scan_function):
|
||||||
scan_function(*args, **kwargs)
|
scan_function(*args, **kwargs)
|
||||||
|
|
||||||
def close(self):
|
def cleanup(self):
|
||||||
super().close()
|
self.button_stop_scan.cleanup()
|
||||||
|
if self.arg_box:
|
||||||
|
for widget in self.arg_box.widgets:
|
||||||
|
if hasattr(widget, "cleanup"):
|
||||||
|
widget.cleanup()
|
||||||
|
for kwarg_box in self.kwarg_boxes:
|
||||||
|
for widget in kwarg_box.widgets:
|
||||||
|
if hasattr(widget, "cleanup"):
|
||||||
|
widget.cleanup()
|
||||||
|
super().cleanup()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
self.cleanup()
|
||||||
|
QWidget().closeEvent(event)
|
||||||
|
|
||||||
|
|
||||||
# Application example
|
# Application example
|
||||||
|
Reference in New Issue
Block a user