0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 11:41:49 +02:00

fix: widget_io print_widget_hierarchy fix comboboxes

This commit is contained in:
wyzula-jan
2023-12-06 09:44:32 +01:00
parent bcc47f3740
commit d1f9979ab1

View File

@ -147,15 +147,20 @@ class WidgetIO:
class WidgetHierarchy: class WidgetHierarchy:
@staticmethod @staticmethod
def print_widget_hierarchy( def print_widget_hierarchy(
widget, indent: int = 0, grab_values: bool = False, prefix: str = "" widget,
indent: int = 0,
grab_values: bool = False,
prefix: str = "",
exclude_internal_widgets: bool = True,
) -> None: ) -> None:
""" """
Print the widget hierarchy to the console. Print the widget hierarchy to the console.
Args: Args:
widget: Widget to print the hierarchy of. widget: Widget to print the hierarchy of
indent(int, optional): Level of indentation. indent(int, optional): Level of indentation.
grab_values(bool,optional): Whether to grab the values of the widgets. grab_values(bool,optional): Whether to grab the values of the widgets.
prefix(stc,optional): Custom string prefix for indentation. prefix(stc,optional): Custom string prefix for indentation.
exclude_internal_widgets(bool,optional): Whether to exclude internal widgets (e.g. QComboBox in PyQt6).
""" """
widget_info = f"{widget.__class__.__name__} ({widget.objectName()})" widget_info = f"{widget.__class__.__name__} ({widget.objectName()})"
if grab_values: if grab_values:
@ -167,6 +172,12 @@ class WidgetHierarchy:
children = widget.children() children = widget.children()
for child in children: for child in children:
if (
exclude_internal_widgets
and isinstance(widget, QComboBox)
and child.__class__.__name__ in ["QFrame", "QBoxLayout", "QListView"]
):
continue
child_prefix = prefix + " " child_prefix = prefix + " "
arrow = "├─ " if child != children[-1] else "└─ " arrow = "├─ " if child != children[-1] else "└─ "
WidgetHierarchy.print_widget_hierarchy( WidgetHierarchy.print_widget_hierarchy(