diff --git a/gui/tabs/query_tab.py b/gui/tabs/query_tab.py index adb25e9..4c313ad 100644 --- a/gui/tabs/query_tab.py +++ b/gui/tabs/query_tab.py @@ -650,7 +650,7 @@ class QueryTab(ctk.CTkFrame): # ── Results Treeview population ──────────────────────────────── def _populate_results(self, columns: list[str], rows: list[list]): - """Clear and populate the results Treeview.""" + """Clear and populate the results Treeview with auto-sized columns.""" self._results_tree.delete(*self._results_tree.get_children()) if not columns: @@ -658,9 +658,28 @@ class QueryTab(ctk.CTkFrame): return self._results_tree["columns"] = columns - for col in columns: + + # Measure optimal width per column: max(header, data) + padding + import tkinter.font as tkfont + heading_font = tkfont.Font(family="Segoe UI", size=10, weight="bold") + data_font = tkfont.Font(family="Consolas", size=11) + + col_widths = [] + for i, col in enumerate(columns): + max_w = heading_font.measure(col) + 20 # header + sort arrow space + # Sample up to 100 rows to avoid slow measuring on huge result sets + for row in rows[:100]: + val = str(row[i]) if i < len(row) and row[i] is not None else "NULL" + w = data_font.measure(val) + 16 # data + padding + if w > max_w: + max_w = w + # Clamp: min 60px, max 400px + col_widths.append(max(60, min(400, max_w))) + + for col, width in zip(columns, col_widths): self._results_tree.heading(col, text=col, anchor="w") - self._results_tree.column(col, width=120, minwidth=60, anchor="w") + self._results_tree.column(col, width=width, minwidth=60, + anchor="w", stretch=False) for row in rows: display = [str(v) if v is not None else "NULL" for v in row] diff --git a/releases/ServerManager-v1.8.57-win-x64.exe b/releases/ServerManager-v1.8.57-win-x64.exe new file mode 100644 index 0000000..1e270d6 Binary files /dev/null and b/releases/ServerManager-v1.8.57-win-x64.exe differ diff --git a/version.py b/version.py index 78f413d..486ac9e 100644 --- a/version.py +++ b/version.py @@ -1,6 +1,6 @@ """Version info for ServerManager.""" -__version__ = "1.8.56" +__version__ = "1.8.57" __app_name__ = "ServerManager" __author__ = "aibot777" __description__ = "Desktop GUI for managing remote servers"