Skip to main content

A library which is intended to simplify a placement of widgets with .grid() and .pack() methods

Project description

Tkinter Layout Helpers

Python package documentation Coverage Status PyPI

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:

import tkinter as tk
from tkinter_layout_helpers.grid_helper import grid_manager

root = tk.Tk()

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))

    with grid.new_row() as row:
        row.add(tk.Entry()).column_span(4)
        row.add(tk.Entry()).column_span(1)
    
    with grid.new_row() as row:
        row.add(tk.Entry()).column_span(3)
        row.add(tk.Entry()).column_span(2)
    
    with grid.new_row() as row:
        row.add(tk.Entry()).column_span(2)
        row.add(tk.Entry()).column_span(3)

    with grid.new_row() as row:
        row.add(tk.Entry()).column_span(1)
        row.add(tk.Entry()).column_span(4)

    for column in grid.columns:
        column.configure(weight=1)

root.mainloop()

Gives the following result:

image

Example for the pack_manager:

import tkinter as tk

from tkinter_layout_helpers import pack_manager

root = tk.Tk()

with pack_manager(root, fill=tk.BOTH) as packer:
    packer.pack_left(tk.Label(text="Left bar", relief=tk.RAISED))
    packer.pack_top(tk.Label(text="Top bar", relief=tk.RAISED))
    packer.pack_bottom(tk.Label(text="Bottom bar", relief=tk.RAISED))
    packer.pack_right(tk.Label(text="Right bar", relief=tk.RAISED))
    packer.pack_expanded(tk.Text())

root.mainloop()

Result:

image

More examples see here: examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkinter_layout_helpers-0.5.0.tar.gz (55.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkinter_layout_helpers-0.5.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file tkinter_layout_helpers-0.5.0.tar.gz.

File metadata

  • Download URL: tkinter_layout_helpers-0.5.0.tar.gz
  • Upload date:
  • Size: 55.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for tkinter_layout_helpers-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8c9440f93055e61286808355eafc60481175751ad06d3b13d9a9e8fff214be52
MD5 55953a837be856babc3065773fc7289d
BLAKE2b-256 234e36bd6e1f61f4d29331037d8bd6f4f8a3cf35f4861e464bef5dc91cd76a28

See more details on using hashes here.

Provenance

The following attestation bundles were made for tkinter_layout_helpers-0.5.0.tar.gz:

Publisher: pypi-deploy.yml on insolor/tkinter-layout-helpers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tkinter_layout_helpers-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tkinter_layout_helpers-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7889ec87f24321fc2193babb03cdc69a7411e8f9b81bc29dde31f4bcb080af6
MD5 5bfb5741e4a86d04de2d91c421cfc75a
BLAKE2b-256 d3c6f556627b0c26dac7e4f4f989c3e6f0bac6defc2c876605c074fdd1124984

See more details on using hashes here.

Provenance

The following attestation bundles were made for tkinter_layout_helpers-0.5.0-py3-none-any.whl:

Publisher: pypi-deploy.yml on insolor/tkinter-layout-helpers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page