Public API
grid_manager(parent, **kwargs)
A context manager to create a grid of widgets. It is intended to simplify a placement of widgets with .grid()
.
Basicly, it is a wrapper around Grid
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 grid_manager(root, sticky=tk.EW) as grid:
with grid.new_row() as row:
row.add(tk.Label(text="0", width=20))
row.add(tk.Label(text="1", width=20))
row.add(tk.Label(text="2", width=20))
row.add(tk.Label(text="3", width=20))
row.add(tk.Label(text="4", width=20))
Source code in tkinter_layout_helpers/grid_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())
Source code in tkinter_layout_helpers/pack_helper.py
set_parent(parent)
Set the parent widget for all widgets created within the with
statement scope,
so you will not have to pass the parent for every created widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent
|
TParent
|
parent widget |
required |