Skip to main content

A scrollable, collapsible section-based content renderer for tkinter.

Project description

tkblocks Project Status

A scrollable, collapsible section-based content renderer for tkinter.

Drop-in collapsible section panels for tkinter apps — load content from Python, JSON, YAML, or TOML.

tkblocks is a simple, tested and predictable tkinter implementation that complies with your app's existing theme and style.

  • Import tkblocks
  • Pass a notebook tab or plain frame.
  • Provide content with json, yaml, toml or python API.

Useful for:

  • FAQ panels
  • Changelogs / release notes
  • Settings/help dialogs
  • Onboarding flows
  • Dashboards with collapsible read-only data sections
  • Debug/log viewers

Installation

pip install tkblocks

Optional dependencies based on content types used:

pip install pyyaml    # for .yaml/.yml content files
pip install requests  # for WebImageContent

Usage

Python API

from tkblocks import Blocks, SectionData, TextContent, LinkContent, LocalImageContent

sections = [
    SectionData(
        title="Getting Started",
        contents=[
            TextContent(text="Welcome to the app."),
            LinkContent(text="Documentation", url="https://example.com"),
        ],
    ),
    SectionData(
        title="Resources",
        contents=[
            LocalImageContent(text="Overview", path="media/overview.png"),
        ],
    ),
]

blocks = Blocks(parent, sections_data=sections, title="📖 User Guide")
blocks.pack(fill="both", expand=True)

Loading from file

from tkblocks import Blocks, load_sections

blocks = Blocks(parent, sections_data=load_sections("guide.toml"), title="📖 User Guide")
blocks.pack(fill="both", expand=True)

Supported formats: .json, .yaml, .yml, .toml

Example TOML file

[[sections]]
title = "Getting Started"

[[sections.contents]]
type = "text"
text = """
Welcome to the app.
This is a multiline description.
"""

[[sections.contents]]
type = "link"
text = "Documentation"
url = "https://example.com"

[[sections]]
title = "Resources"

[[sections.contents]]
type = "local_image"
text = "Overview diagram"
path = "media/overview.png"

Importing

Always import from the top-level package:

from tkblocks import Blocks, load_sections  # ✅
from tkblocks.blocks import Blocks          # ❌ not guaranteed stable

Content block types

Type Class Required fields
Plain text TextContent text
Copyable text CopyableContent text
Hyperlink LinkContent text, url
Local image LocalImageContent path
Web image WebImageContent url

Requirements

  • Python >= 3.11
  • Pillow
  • Pydantic

License

Apache 2.0 — see LICENSE for details.

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

tkblocks-0.1.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

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

tkblocks-0.1.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file tkblocks-0.1.1.tar.gz.

File metadata

  • Download URL: tkblocks-0.1.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for tkblocks-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8eea9ef588c6f0b4eb03b3da70b04078fc36d19a9399a404d32286862369ac05
MD5 81d65943bc880a1749e0cab871af0c6b
BLAKE2b-256 08bae12556ee610342e568e2124f30f280e1d85d31b524339d34d12551616411

See more details on using hashes here.

File details

Details for the file tkblocks-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tkblocks-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for tkblocks-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7e21bd8c5a5a752029a34cec7e65a126ac7a14e268762e16927638aa5a0e6e9
MD5 010c3da48c1bea3ba6a17a67ff54a30b
BLAKE2b-256 7832f19bc8a9749ed8bc9c584e4846c7aade725aee1b6b8049d701f5ef31eba0

See more details on using hashes here.

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