|
1 | 1 | #!/usr/bin/python3 |
2 | | -version = __version__ = "4.55.1.10 Unreleased" |
| 2 | +version = __version__ = "4.55.1.11 Unreleased" |
3 | 3 |
|
4 | 4 | _change_log = """ |
5 | 5 | Changelog since 4.55.1 released to PyPI on 7-Nov-2021 |
|
35 | 35 | Don't print the error message about wm_overrideredirect while hiding the master root if running on a Mac. |
36 | 36 | 4.55.1.10 |
37 | 37 | Fix for Tree Element not setting the row height if none is specified. Needed to set to value based on the font used. |
| 38 | + 4.55.1.11 |
| 39 | + Tree Element |
| 40 | + * Always left justify the first column. This is how it's always worked. tkinter 8.6.12 changed the behavior of the first col. This changes it back |
| 41 | + * Better auto-size column. Uses the data as well as the Column header to determine size of column |
| 42 | + |
38 | 43 | """ |
39 | 44 |
|
40 | 45 | __version__ = version.split()[0] # For PEP 396 and PEP 345 |
@@ -15304,10 +15309,19 @@ def _add_expansion(element, row_should_expand, row_fill_direction): |
15304 | 15309 | height=height, |
15305 | 15310 | selectmode=element.SelectMode) |
15306 | 15311 | treeview = element.TKTreeview |
| 15312 | + max_widths = {} |
| 15313 | + for key, node in element.TreeData.tree_dict.items(): |
| 15314 | + for i, value in enumerate(node.values): |
| 15315 | + max_width = max_widths.get(i, 0) |
| 15316 | + if len(str(value)) > max_width: |
| 15317 | + max_widths[i] = len(str(value)) |
| 15318 | + |
15307 | 15319 | for i, heading in enumerate(element.ColumnHeadings): # Configure cols + headings |
15308 | 15320 | treeview.heading(heading, text=heading) |
15309 | 15321 | if element.AutoSizeColumns: |
15310 | | - width = min(element.MaxColumnWidth, len(heading) + 1) |
| 15322 | + max_width = max_widths.get(i, 0) |
| 15323 | + max_width = max(max_width, len(heading)) |
| 15324 | + width = min(element.MaxColumnWidth, max_width+1) |
15311 | 15325 | else: |
15312 | 15326 | try: |
15313 | 15327 | width = element.ColumnWidths[i] |
@@ -15351,7 +15365,7 @@ def add_treeview_data(node): |
15351 | 15365 | add_treeview_data(node) |
15352 | 15366 |
|
15353 | 15367 | add_treeview_data(element.TreeData.root_node) |
15354 | | - treeview.column('#0', width=element.Col0Width * _char_width_in_pixels(font), anchor=anchor) |
| 15368 | + treeview.column('#0', width=element.Col0Width * _char_width_in_pixels(font), anchor=tk.W) |
15355 | 15369 | # ----- configure colors ----- |
15356 | 15370 | # style_name = str(element.Key) + '.Treeview' |
15357 | 15371 | style_name = _make_ttk_style_name('.Treeview', element) |
|
0 commit comments