Skip to main content

Lofi GUI tooling

Project description

lofigui

Latest: v0.17.28

Lofi GUI - A minimalist Go library for creating really simple web-based GUIs for CLI tools and small projects. It provides a print-like interface for building lightweight web UIs with minimal complexity.

The application is where you have a single real object (e.g. machine or long-running process) which then has a number of pages around it to show various aspects of it.

Go Version License: MIT

Overview

lofigui provides a print-like interface for building lightweight web applications with minimal complexity. Perfect for:

  • Creating quick GUIs for command-line tools
  • Internal tools for small teams (1-10 users)
  • Single-process or single-object front-ends
  • Rapid prototyping without JavaScript overhead

Key Features

  • Simple API: Print-like interface (Print(), Markdown(), HTML(), Table())
  • No JavaScript: Pure HTML/CSS using the Bulma framework
  • Single binary: Deploy as one executable, no dependencies
  • WebAssembly: Same code runs in the browser via WASM
  • Built-in layouts: LayoutSingle, LayoutNavbar, LayoutThreePanel

Quick Start

package main

import (
    "net/http"
    "codeberg.org/hum3/lofigui"
)

func model(app *lofigui.App) {
    lofigui.Print("Hello world")
    app.EndAction()
}

func main() {
    ctrl, _ := lofigui.NewControllerWithLayout(lofigui.LayoutNavbar, "My App")
    app := lofigui.NewApp()
    app.SetController(ctrl)
    app.SetDisplayURL("/display")

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        app.HandleRoot(w, r, model, true)
    })
    http.HandleFunc("/display", func(w http.ResponseWriter, r *http.Request) {
        app.HandleDisplay(w, r)
    })
    http.HandleFunc("/favicon.ico", lofigui.ServeFavicon)
    http.ListenAndServe(":8080", nil)
}

Element

Your project is essentially a web site. To make design simple you completely refresh pages so no code for partial refreshes. To make things dynamic it has to be asynchronous, using goroutines for background processing.

Like a normal terminal program you essentially just print things to a screen but now have the ability to print enriched objects.

Model View Controller architecture

All I really want to do is to write the model. The controller and view (in the browser and templating system) are a necessary evil. The controller includes the routing and web server. The controller is split between the app (single instance) and a model-specific controller. The view is the HTML templating (pongo2) and the browser.

Buffer

In order to decouple the display from the output and be able to refresh, you need to buffer the output. It is more efficient to buffer the output in the browser but more complicated. Moving the buffer to the server simplifies the software but requires you to refresh the whole page. lofigui relies on hyperlinks to perform updates. HTMX plays nicely here for improving interactivity (examples 09-10).

Installation

go get codeberg.org/hum3/lofigui

Examples & Documentation

See the documentation site for interactive examples (including WASM demos), research notes, and the roadmap.

To run examples locally, use Task:

task --list              # Show all available tasks
task go-example:09       # Run any Go example by number

Python

A Python implementation also exists with the same API using FastAPI and Jinja2. See Python Notes for installation, API reference, and development instructions.

Roadmap

See ROADMAP.md for planned features and future direction.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE file for details.

Author

Humphrey Drummond - hum3@drummond.info

Links

Documentation https://h3-lofigui.statichost.page/
PyPI https://pypi.org/project/lofigui/
Source (Codeberg) https://codeberg.org/hum3/lofigui
Mirror (GitHub) https://github.com/drummonds/lofigui

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

lofigui-0.17.28.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

lofigui-0.17.28-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file lofigui-0.17.28.tar.gz.

File metadata

  • Download URL: lofigui-0.17.28.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lofigui-0.17.28.tar.gz
Algorithm Hash digest
SHA256 037f4ce6a8693211e05f8a8c2afaa53bd8c2efd13ef9022b1444c3db5fe989d7
MD5 9d606e0e5ecd843c7b8f2d6a8230b467
BLAKE2b-256 4138a8e9806f7098f9240cefb33d7d90cca51d330864a4d7ff7ad0d4b25ff729

See more details on using hashes here.

File details

Details for the file lofigui-0.17.28-py3-none-any.whl.

File metadata

  • Download URL: lofigui-0.17.28-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for lofigui-0.17.28-py3-none-any.whl
Algorithm Hash digest
SHA256 84f468ce66ede40eb3f25a1368254e1d31db5dc5362cb541806fcbae463376f8
MD5 8a9be716bc540c2430d2a30262315029
BLAKE2b-256 9cc94cdfcfeafdbed17103c649129080a90b2159a83a93f2e849f73bec63426d

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