From 1f720033690dd5dd2bbdddc9b1a40e9012e0f4a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Nov 2023 10:07:59 +0100 Subject: [PATCH 1/2] this is annoying --- tmtccmd/gui/cmd_select.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tmtccmd/gui/cmd_select.py b/tmtccmd/gui/cmd_select.py index a2a764a5..27e08a35 100644 --- a/tmtccmd/gui/cmd_select.py +++ b/tmtccmd/gui/cmd_select.py @@ -5,9 +5,11 @@ QHBoxLayout, QLabel, QPushButton, + QSizePolicy, QTreeView, QVBoxLayout, QWidget, + QLayout, ) from tmtccmd.config.tmtc import CmdTreeNode @@ -40,6 +42,11 @@ def init_ui(self): self.tree_view = QTreeView() self.tree_view.setModel(self.tree_model) self.tree_view.expanded.connect(self.on_item_expanded) + print(f"tree view size policy: {self.tree_view.sizePolicy().horizontalPolicy()!r}") + print(f"tree view size policy: {self.tree_view.sizePolicy().verticalPolicy()!r}") + self.tree_view.setSizePolicy( + QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.MinimumExpanding + ) self.expand_full_button = QPushButton("Expand All") self.expand_full_button.clicked.connect(self.expand_all_items) @@ -68,6 +75,11 @@ def init_ui(self): layout.addWidget(self.path_label) layout.addWidget(self.path_confirmed_button) self.setLayout(layout) + print(f"wdiget size policy: {self.sizePolicy().horizontalPolicy()!r}") + print(f"wdiget size policy: {self.sizePolicy().verticalPolicy()!r}") + self.setSizePolicy( + QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.MinimumExpanding + ) def expand_all_items(self): self.tree_view.expandAll() @@ -98,6 +110,10 @@ def on_item_expanded(self, _index: int): self.tree_view.resizeColumnToContents( CommandPathSelectWidget.DESCRIPTION_COLUMN ) + self.resize( + self.tree_view.sizeHintForColumn(0) + self.tree_view.sizeHintForColumn(1), + self.size().height(), + ) def select_path_clicked(self): selected_indexes = self.tree_view.selectedIndexes() From 8c80d2be24106203fe3ed0d8b906e2daf1774831 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Nov 2023 10:57:25 +0100 Subject: [PATCH 2/2] I guess this is sufficient --- tmtccmd/gui/cmd_select.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tmtccmd/gui/cmd_select.py b/tmtccmd/gui/cmd_select.py index 27e08a35..442f0244 100644 --- a/tmtccmd/gui/cmd_select.py +++ b/tmtccmd/gui/cmd_select.py @@ -5,11 +5,9 @@ QHBoxLayout, QLabel, QPushButton, - QSizePolicy, QTreeView, QVBoxLayout, QWidget, - QLayout, ) from tmtccmd.config.tmtc import CmdTreeNode @@ -42,11 +40,6 @@ def init_ui(self): self.tree_view = QTreeView() self.tree_view.setModel(self.tree_model) self.tree_view.expanded.connect(self.on_item_expanded) - print(f"tree view size policy: {self.tree_view.sizePolicy().horizontalPolicy()!r}") - print(f"tree view size policy: {self.tree_view.sizePolicy().verticalPolicy()!r}") - self.tree_view.setSizePolicy( - QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.MinimumExpanding - ) self.expand_full_button = QPushButton("Expand All") self.expand_full_button.clicked.connect(self.expand_all_items) @@ -75,11 +68,6 @@ def init_ui(self): layout.addWidget(self.path_label) layout.addWidget(self.path_confirmed_button) self.setLayout(layout) - print(f"wdiget size policy: {self.sizePolicy().horizontalPolicy()!r}") - print(f"wdiget size policy: {self.sizePolicy().verticalPolicy()!r}") - self.setSizePolicy( - QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.MinimumExpanding - ) def expand_all_items(self): self.tree_view.expandAll() @@ -111,7 +99,11 @@ def on_item_expanded(self, _index: int): CommandPathSelectWidget.DESCRIPTION_COLUMN ) self.resize( - self.tree_view.sizeHintForColumn(0) + self.tree_view.sizeHintForColumn(1), + self.tree_view.sizeHintForColumn(CommandPathSelectWidget.NODE_NAME_COLUMN) + + self.tree_view.sizeHintForColumn( + CommandPathSelectWidget.DESCRIPTION_COLUMN + ) + + 40, self.size().height(), )