File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 1
1
=======
2
2
History
3
3
=======
4
-
4
+ 2024.7.21 -- Return the width of aligned labels
5
+ * The align_labels procedure now returns the width of the labels. This is useful for
6
+ laying out indented widgets.
7
+
5
8
2024.5.1 -- Enhancement to ScrolledColumns
6
9
* Added optional separator columns for dividing sections of the table.
7
10
Original file line number Diff line number Diff line change 40
40
}
41
41
42
42
43
- def align_labels (widgets , sticky = None ):
43
+ def align_labels (widgets , sticky = tk . E ):
44
44
"""Align the labels of a given list of widgets"""
45
- if len (widgets ) <= 1 :
46
- return
45
+ if len (widgets ) == 0 :
46
+ return 0
47
47
48
48
widgets [0 ].update_idletasks ()
49
49
@@ -56,10 +56,13 @@ def align_labels(widgets, sticky=None):
56
56
57
57
# Adjust the margins for the labels such that the child sites and
58
58
# labels line up.
59
- for widget in widgets :
60
- if sticky is not None :
61
- widget .label .grid (sticky = sticky )
62
- widget .grid_columnconfigure (0 , minsize = max_width )
59
+ if len (widgets ) > 1 :
60
+ for widget in widgets :
61
+ if sticky is not None :
62
+ widget .label .grid (sticky = sticky )
63
+ widget .grid_columnconfigure (0 , minsize = max_width )
64
+
65
+ return max_width
63
66
64
67
65
68
class LabeledWidget (ttk .Frame ):
You can’t perform that action at this time.
0 commit comments