0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

feat(image_widget): plugin added

This commit is contained in:
2024-07-20 17:23:45 +02:00
committed by wyzula_j
parent 3d2ca4855c
commit 43711680ba
4 changed files with 75 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -0,0 +1 @@
{'files': ['image_widget.py']}

View File

@ -0,0 +1,59 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import os
from qtpy.QtDesigner import QDesignerCustomWidgetInterface
from qtpy.QtGui import QIcon
import bec_widgets
from bec_widgets.widgets.image.image_widget import BECImageWidget
DOM_XML = """
<ui language='c++'>
<widget class='BECImageWidget' name='bec_image_widget'>
</widget>
</ui>
"""
MODULE_PATH = os.path.dirname(bec_widgets.__file__)
class BECImageWidgetPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
def __init__(self):
super().__init__()
self._form_editor = None
def createWidget(self, parent):
t = BECImageWidget(parent)
return t
def domXml(self):
return DOM_XML
def group(self):
return "BEC Plots"
def icon(self):
icon_path = os.path.join(MODULE_PATH, "assets", "designer_icons", "image.png")
return QIcon(icon_path)
def includeFile(self):
return "bec_image_widget"
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 "BECImageWidget"
def toolTip(self):
return "BECImageWidget"
def whatsThis(self):
return self.toolTip()

View 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.image.bec_image_widget_plugin import BECImageWidgetPlugin
QPyDesignerCustomWidgetCollection.addCustomWidget(BECImageWidgetPlugin())
if __name__ == "__main__": # pragma: no cover
main()