Pack Helper
Packer
Bases: Generic[TParent]
Builder class to pack widgets in a window or a frame.
Source code in tkinter_layout_helpers/pack_helper.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
__init__(parent, **kwargs)
Initialize a packer object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
TParent
|
parent widget |
required |
kwargs
|
common parameters to configure the widgets placement with |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack(widget, **kwargs)
Pack a widget in a window or a frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget
|
Widget
|
widget to pack |
required |
kwargs
|
all additional parameters to configure the widget's position. |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_all(*args, **kwargs)
Pack all widgets in a window or a frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args
|
Widget
|
widgets to pack |
()
|
kwargs
|
all additional parameters to configure the widgets placement with |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_bottom(widget, **kwargs)
Pack a widget in a window or a frame to the bottom.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget
|
Widget
|
widget to pack |
required |
kwargs
|
all additional parameters to configure the widget's position. |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_expanded(widget, **kwargs)
Pack a widget in a window or a frame expanded.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget
|
Widget
|
widget to pack |
required |
kwargs
|
all additional parameters to configure the widget's position. |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_left(widget, **kwargs)
Pack a widget in a window or a frame to the left.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget
|
Widget
|
widget to pack |
required |
kwargs
|
all additional parameters to configure the widget's position. |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_right(widget, **kwargs)
Pack a widget in a window or a frame to the right.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget
|
Widget
|
widget to pack |
required |
kwargs
|
all additional parameters to configure the widget's position. |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_top(widget, **kwargs)
Pack a widget in a window or a frame to the top.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget
|
Widget
|
widget to pack |
required |
kwargs
|
all additional parameters to configure the widget's position. |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_expanded(widget, **kwargs)
Pack a widget in a parent widget expanded.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widget
|
Widget
|
widget to pack |
required |
kwargs
|
all additional parameters to configure the widget's position in the cell |
{}
|
Source code in tkinter_layout_helpers/pack_helper.py
pack_manager(parent, **kwargs)
A context manager to help to place widgets in window or a frame using .pack()
method.
Basicly, it is a wrapper around Packer
class, but additionaly, it sets the parent widget of a grid
(within the with
statement scope), so you don't need to specify it explicitly for every widget.
Usage example:
with pack_manager(root, fill=tk.BOTH, relief=tk.RAISED) as packer:
packer.pack_left(tk.Label(text="Left bar"))
packer.pack_top(tk.Label(text="Top bar"))
packer.pack_bottom(tk.Label(text="Bottom bar"))
packer.pack_right(tk.Label(text="Right bar"))
packer.pack_expanded(tk.Text())