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.2.tar.gz (14.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.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tkblocks-0.1.2.tar.gz
  • Upload date:
  • Size: 14.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.2.tar.gz
Algorithm Hash digest
SHA256 b2824676819884ed595035375c35adcf52bfb3cbcda813647e2b7d7981aa5bcb
MD5 11e501e4b066a65e1298670ae31fffc8
BLAKE2b-256 f9b84cd8fcc621939b4926a7adc8be709fdf5b866e414da5b0ad3b1c309069d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tkblocks-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc6700a275097a62e56be7bb759a405646db56bc9306bb698e9d0635f4c23356
MD5 826e8451c8179327e003cee994deea35
BLAKE2b-256 ed114566492e33261488a9bec5276e9c8e450ece5c41904ee420a259a934f137

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