Skip to main content

A reusable tkinter/ttkbootstrap UI framework

Project description

Jabs Mimir

Jabs Mimir is a lightweight, extensible UI micro-framework built on top of tkinter and ttkbootstrap, designed for rapid internal tool development and structured form workflows.

It provides:

  • Reusable UI primitives with validation and tooltips
  • Support for block-based form components with dynamic variable binding
  • Integration with custom validation logic (via resolver, file loader, or direct function)
  • Modular architecture suitable for internal tooling and small boilerplate projects

Installation

pip install jabs-mimir

Quick Start

from jabs_mimir import Mimir, DataBlockWrapper, UtilityModule
import tkinter as tk
import ttkbootstrap as tb

class App(tb.Window):
    def __init__(self):
        super().__init__(title="Mimir Demo")
        self.ui = Mimir(self)

        # Option 1: Inline validator resolver (string-based)
        self.ui.setValidatorResolver(lambda name: {
            "notEmpty": lambda val: bool(str(val).strip())
        }.get(name))

        # Option 2 (alternative): load from file
        # self.ui.setValidatorFile("include/validator.py")

        self.ui.switchView(self.mainView)

    def mainView(self, ui, *args):
        frame = tb.Frame(self)
        fields = [
            {"type": "heading", "label": "Basic Info"},
            {"label": "Name", "key": "name", "variable": tk.StringVar(), "validation": "notEmpty"},
            {"label": "Age", "key": "age", "variable": tk.IntVar()}
        ]

        meta = UtilityModule.buildBlockMeta(fields)
        block = DataBlockWrapper(meta)

        ui.renderFields(frame, fields)
        ui.addNextButton(frame, row=len(fields)+1, command=lambda: print(UtilityModule.getBlockValues(block)))

        return frame

if __name__ == "__main__":
    app = App()
    app.mainloop()

Validation

Jabs Mimir supports both automatic and manual validation, triggered on field focus-out and verified again when clicking "Nästa".

You can define validation in two ways:

1. String-based validation (via file or resolver)

Define a validator in a file:

# include/validator.py
def notEmpty(value):
    return bool(str(value).strip())

Load it:

self.ui.setValidatorFile("include/validator.py")

Use string key in field:

{"label": "Name", "variable": tk.StringVar(), "validation": "notEmpty"}

2. Direct function reference

from include.validator import notEmpty

fields = [
    {"label": "Name", "variable": tk.StringVar(), "validation": notEmpty}
]

Both methods are fully supported and interchangeable.

Mimir automatically:

  • Binds validation on focus-out
  • Stores all validators internally
  • Re-validates all fields when clicking "Nästa"
  • Blocks navigation if any invalid inputs remain
  • Highlights invalid fields with red styling

Works even for readonly fields (like file upload paths), which normally can't be focused.


Components

Mimir

Manages UI views, tooltips, validation, field rendering, and form logic. Supports reusable custom field types via registerFieldType().

DataBlockWrapper

A wrapper for block-level form metadata and values. Supports dot-access and .get()/.set() calls.

UtilityModule

Helper methods for building field metadata, extracting values, validating blocks, and block meta handling.


License

MIT License © 2025 William Lydahl

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

jabs_mimir-0.5.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

jabs_mimir-0.5.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file jabs_mimir-0.5.1.tar.gz.

File metadata

  • Download URL: jabs_mimir-0.5.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for jabs_mimir-0.5.1.tar.gz
Algorithm Hash digest
SHA256 2251a89491d9ac6c8058b4debb1672c4077cc0df027e72c330707e566178fa7b
MD5 392796022b200dd77374d18b31f9ad87
BLAKE2b-256 f01af80410b98b2ae4f3f46fb8793b3e877b4e80c2b6aa4d03a47ef374c4ab75

See more details on using hashes here.

File details

Details for the file jabs_mimir-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: jabs_mimir-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for jabs_mimir-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a460eaaad93b1bd996459cd07f8f6a5c74426218fc14f9b07d8787a79c6d27c3
MD5 795861dfcb6450695457e601c53534b8
BLAKE2b-256 d47b13be84fa00bc21e28c0aa74ffb5cf6226e4abf520da4eda739adb5af9a6f

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