mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-03-11 11:17:49 +01:00
feat(scan_control): plugin added for QtDesigner
This commit is contained in:
15
bec_widgets/widgets/scan_control/register_scan_control.py
Normal file
15
bec_widgets/widgets/scan_control/register_scan_control.py
Normal file
@@ -0,0 +1,15 @@
|
||||
def main(): # pragma: no cover
|
||||
from qtpy import PYSIDE6
|
||||
|
||||
if not PYSIDE6:
|
||||
print("PYSIDE6 is not available in the environment. Cannot patch designer.")
|
||||
return
|
||||
from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
|
||||
|
||||
from bec_widgets.widgets.scan_control.scan_control_plugin import ScanControlPlugin
|
||||
|
||||
QPyDesignerCustomWidgetCollection.addCustomWidget(ScanControlPlugin())
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
main()
|
||||
3
bec_widgets/widgets/scan_control/scan_control.pyproject
Normal file
3
bec_widgets/widgets/scan_control/scan_control.pyproject
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"files": ["scan_control.py","scan_control_box.py"]
|
||||
}
|
||||
51
bec_widgets/widgets/scan_control/scan_control_plugin.py
Normal file
51
bec_widgets/widgets/scan_control/scan_control_plugin.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from qtpy.QtDesigner import QDesignerCustomWidgetInterface
|
||||
from qtpy.QtGui import QIcon
|
||||
|
||||
from bec_widgets.widgets.scan_control import ScanControl
|
||||
|
||||
DOM_XML = """
|
||||
<ui language='c++'>
|
||||
<widget class='ScanControl' name='scan_control'>
|
||||
</widget>
|
||||
</ui>
|
||||
"""
|
||||
|
||||
|
||||
class ScanControlPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._form_editor = None
|
||||
|
||||
def createWidget(self, parent):
|
||||
t = ScanControl(parent)
|
||||
return t
|
||||
|
||||
def domXml(self):
|
||||
return DOM_XML
|
||||
|
||||
def group(self):
|
||||
return ""
|
||||
|
||||
def icon(self):
|
||||
return QIcon()
|
||||
|
||||
def includeFile(self):
|
||||
return "scan_control"
|
||||
|
||||
def initialize(self, form_editor):
|
||||
self._form_editor = form_editor
|
||||
|
||||
def isContainer(self):
|
||||
return False
|
||||
|
||||
def isInitialized(self):
|
||||
return self._form_editor is not None
|
||||
|
||||
def name(self):
|
||||
return "ScanControl"
|
||||
|
||||
def toolTip(self):
|
||||
return "ScanControl widget"
|
||||
|
||||
def whatsThis(self):
|
||||
return self.toolTip()
|
||||
Reference in New Issue
Block a user