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

WIP log panel no initialisation for designer testing proof of concept

This commit is contained in:
2025-04-06 12:02:17 +02:00
parent 8762d17e31
commit 794104ac6a
2 changed files with 15 additions and 6 deletions

View File

@ -1,7 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from qtpy.QtDesigner import QDesignerCustomWidgetInterface
from qtpy.QtWidgets import QWidget
from bec_widgets.utils.bec_designer import designer_material_icon
from bec_widgets.widgets.utility.logpanel.logpanel import LogPanel
@ -17,11 +15,17 @@ DOM_XML = """
class LogPanelPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
def __init__(self):
super().__init__()
self._initialized = False
self._form_editor = None
def createWidget(self, parent):
t = LogPanel(parent)
return t
# 1) Detect if Qt Designer is just enumerating your widget for the palette
if parent is None:
# Return a minimal stub (or do nothing) so you dont initialize LogPanel fully
return QWidget()
# 2) Otherwise, create the real widget
return LogPanel(parent)
def domXml(self):
return DOM_XML
@ -33,16 +37,20 @@ class LogPanelPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
return designer_material_icon(LogPanel.ICON_NAME)
def includeFile(self):
# Return the Python import path for the actual class
return "log_panel"
def initialize(self, form_editor):
if self._initialized:
return
self._form_editor = form_editor
self._initialized = True
def isContainer(self):
return False
def isInitialized(self):
return self._form_editor is not None
return self._initialized
def name(self):
return "LogPanel"

View File

@ -96,6 +96,7 @@ class BecLogsQueue:
self._new_message_signal.disconnect()
def _process_incoming_log_msg(self, msg: dict):
logger.error(f"LogPanel received message {msg}")
try:
_msg: LogMessage = msg["data"]
self._data.append(_msg)