https://github.com/insolor/tkinter-layout-helpers
A library which is intended to simplify a placement of widgets with .grid() and .pack() methods
https://github.com/insolor/tkinter-layout-helpers
tkinter
Last synced: about 1 month ago
JSON representation
A library which is intended to simplify a placement of widgets with .grid() and .pack() methods
- Host: GitHub
- URL: https://github.com/insolor/tkinter-layout-helpers
- Owner: insolor
- License: mit
- Created: 2022-01-14T12:48:34.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-01T15:38:38.000Z (3 months ago)
- Last Synced: 2025-03-26T16:38:14.664Z (about 2 months ago)
- Topics: tkinter
- Language: Python
- Homepage:
- Size: 156 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tkinter Layout Helpers
[](https://github.com/insolor/tkinter-layout-helpers/actions/workflows/python-tests.yml)
[](https://coveralls.io/github/insolor/tkinter-layout-helpers?branch=master)
[](https://pypi.org/project/tkinter-layout-helpers/)
A library which is intended to simplify a placement of widgets with `.grid()` and `.pack()` methods:
- avoid manual calculation of indices of columns and rows when you add a widget;
- avoid typing-in some common parameters (like `sticky=tk.EW`) each time you add a widget;
- and more...Work in progress.
As an example, this code:
```python
import tkinter as tk
from tkinter_layout_helpers.grid_helper import grid_managerroot = tk.Tk()
with grid_manager(root, sticky=tk.EW) as grid:
grid.new_row() \
.add(tk.Label(text="0", width=20)) \
.add(tk.Label(text="1", width=20)) \
.add(tk.Label(text="2", width=20)) \
.add(tk.Label(text="3", width=20)) \
.add(tk.Label(text="4", width=20))grid.new_row().add(tk.Entry()).column_span(4).add(tk.Entry()).column_span(1)
grid.new_row().add(tk.Entry()).column_span(3).add(tk.Entry()).column_span(2)
grid.new_row().add(tk.Entry()).column_span(2).add(tk.Entry()).column_span(3)
grid.new_row().add(tk.Entry()).column_span(1).add(tk.Entry()).column_span(4)grid.columnconfigure(0, weight=1)
grid.columnconfigure(1, weight=1)
grid.columnconfigure(2, weight=1)
grid.columnconfigure(3, weight=1)
grid.columnconfigure(4, weight=1)root.mainloop()
```Gives the following result:

More examples see here: [examples](https://github.com/insolor/tkinter_layout_helpers/tree/master/examples)