From d0bf7f871b17caa635cdd9ed20b6ef5f8b42eb67 Mon Sep 17 00:00:00 2001 From: David Hozic Date: Wed, 31 Jan 2024 09:45:53 +0100 Subject: [PATCH] fix --- docs/source/changelog.rst | 5 +++++ tkclasswiz/__init__.py | 2 +- tkclasswiz/object_frame/frame_struct.py | 10 ++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index ba4bca1..7a67679 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -24,6 +24,11 @@ Glossary Releases --------------------- +v1.4.6 +================ +- Fixed some parameter name lengths not being accommodated for. + + v1.4.5 ================ - Further generic type fixes diff --git a/tkclasswiz/__init__.py b/tkclasswiz/__init__.py index 5cc15f2..e76c898 100644 --- a/tkclasswiz/__init__.py +++ b/tkclasswiz/__init__.py @@ -27,7 +27,7 @@ SOFTWARE. """ -__version__ = "1.4.5" +__version__ = "1.4.6" from .object_frame import * diff --git a/tkclasswiz/object_frame/frame_struct.py b/tkclasswiz/object_frame/frame_struct.py index 4393ffc..33cb881 100644 --- a/tkclasswiz/object_frame/frame_struct.py +++ b/tkclasswiz/object_frame/frame_struct.py @@ -149,16 +149,18 @@ def load_template(): self.remember_gui_data() def _create_fields(self, annotations: dict[str, type], additional_values: dict, frame: ttk.Frame): - label_width = max(*map(len, annotations), 15) - 2 dpi_5 = dpi_scaled(5) dpi_5h = dpi_5 // 2 + labels: list[ttk.Label] = [] for (k, v) in annotations.items(): # Init widgets entry_types = convert_types(v) frame_annotated = ttk.Frame(frame) frame_annotated.pack(fill=tk.BOTH, expand=True, pady=dpi_5) - ttk.Label(frame_annotated, text=k, width=label_width).pack(side="left") + label = ttk.Label(frame_annotated, text=k) + labels.append(label) + label.pack(side="left") # Storage widget with the tooltip for displaying # nicknames on ObjectInfo instances @@ -206,6 +208,10 @@ def _create_fields(self, annotations: dict[str, type], additional_values: dict, combo.pack(fill=tk.X, side="right", expand=True, padx=dpi_5h) self._map[k] = (w, entry_types) + max_width = max(label.winfo_reqwidth() for label in labels) // 5 + for label in labels: + label.config(width=max_width) + def _fill_field_values( self, k: str,