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()).set_column_span(4)
        row.add(tk.Entry()).set_column_span(1)
    
    with grid.new_row() as row:
        row.add(tk.Entry()).set_column_span(3)
        row.add(tk.Entry()).set_column_span(2)
    
    with grid.new_row() as row:
        row.add(tk.Entry()).set_column_span(2)
        row.add(tk.Entry()).set_column_span(3)

    with grid.new_row() as row:
        row.add(tk.Entry()).set_column_span(1)
        row.add(tk.Entry()).set_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.6.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.6.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tkinter_layout_helpers-0.6.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.6.0.tar.gz
Algorithm Hash digest
SHA256 bb9d62694bfee0d2ab85e71dd8a6fde93154372c3f0af06b7485fa89f2371854
MD5 aacad38be507548cc095f92933f44b86
BLAKE2b-256 cc1fd404c1a73481d5a978ac12dd1830a28c7eb8e2bf9028397a6a37ef4412ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for tkinter_layout_helpers-0.6.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.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tkinter_layout_helpers-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ce16756edf4e2dbe5c830de959f9ea9673eee35c9710768f958d6bb32b5f6d2
MD5 aab6810fe4070c2b6a60d66424ecbd09
BLAKE2b-256 abcb71609ae33c4958a6ebe59e20e5a80bdd0320c2f982e84b13fd8db4e726de

See more details on using hashes here.

Provenance

The following attestation bundles were made for tkinter_layout_helpers-0.6.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