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:
@ -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(
|
||||||
|
Reference in New Issue
Block a user