Skip to main content

A tool to design and run dynamic, customizable dashboards directly inside your terminal.

Project description


🖥 Terminal Widgets

This tool enables you to create and run fully customisable dashboards directly in your terminal.

Getting startedConfigurationAdding new widgetsExamplesContributingLicense

Example Image of Terminal Widgets PyPI Version Python Versions License Downloads (all time) Downloads (last month)

⚠️ Note: This package is only compatible with Unix-based systems.


🚀 1. Getting started

1.1 Installation from PyPI

  1. Install: pip install twidgets
  2. Initialize: twidgets init
  3. Run: twidgets

⚠️ Requires Python Version 3.10+

1.2 Installation from Source

  1. Clone this repository
  2. Install dependencies: pip install -r requirements-dev.txt
  3. Initialize configuration: python -m twidgets init
  4. Run: python -m twidgets

⚠️ Requires Python Version 3.10+

For full documentation see Setup Guide.


2. Configuration

2.1 Changing standard colours and configuration at ~/.config/twidgets/base.yaml

If you let anything blank, it will fall back to the standard configuration
However, you will get warned.

Example:

use_standard_terminal_background: False

background_color:
  r: 31  # Red value
  g: 29  # Green value
  b: 67  # Blue value
  
...

2.2 Configure secrets at ~/.config/twidgets/secrets.env

Example:

WEATHER_API_KEY='your_api_key'
WEATHER_CITY='Berlin,DE'
WEATHER_UNITS='metric'
NEWS_FEED_URL='https://feeds.bbci.co.uk/news/rss.xml?edition=uk'
NEWS_FEED_NAME='BCC'

2.3 Adjust widgets and layouts at ~/.config/twidgets/widgets/*.yaml

Example:

name: 'clock'
title: '  Clock'
enabled: True
interval: 1
height: 5
width: 30
y: 4
x: 87
z: 0

weekday_format: '%A'  # day of the week
date_format: '%d.%m.%Y'  # us: '%m.%d.%Y', international: '%Y-%m-%d'
time_format: '%H:%M:%S'  # time

For full documentation see Configuration Guide.


3. Adding new widgets

Adding new widgets is very easy. For a simple widget, that does not require heavy loading (no update function), you only need to define a configuration and 2 python functions

Naming schemes are described here.
You can create an infinite number of widgets, the file names custom.yaml and custom_widget.py are just examples.

3.1 Define Configuration (.yaml)

Create the configuration file at ~/.config/twidgets/widgets/custom.yaml and set interval = 0 for simple widgets:

name: custom
title: My Custom Widget
enabled: true
interval: 0  # For simple widgets (no heavy loading, no `update` function)
height: 7
width: 30
y: 1
x: 1
z: 1

3.2 Write the Widget Logic (.py)

Create the widget's Python file at ~/.config/twidgets/py_widgets/custom_widget.py

Then define draw and build functions.

Example:

from twidgets.core.base import Widget, WidgetContainer, Config, CursesWindowType

# Define the draw function for content
def draw(widget: Widget, widget_container: WidgetContainer) -> None:
    # Initialize the widget title, make it loadable and highlightable
    draw_widget(widget, widget_container)

    # Add your content (list of strings)
    content: list[str] = [
        'Welcome to my new widget!',
        'This is a test.',
        'It was very easy to create.'
    ]
    widget.add_widget_content(content)

# Define the build function
def build(stdscr: CursesWindowType, config: Config) -> Widget:
    return Widget(
        config.name, config.title, config, draw, config.interval, config.dimensions, stdscr,  # exactly this order!
        update_func=None,
        mouse_click_func=None,
        keyboard_func=None,
        init_func=None,
        help_func=None
    )

For full documentation see Widget Guide.


4. Upgrading to 2.0 ⚠️

Version 2.0 introduces breaking changes. Please see the migration guide for instructions on updating your code.


🌅 5. Examples

Example 1 of Terminal Widgets Example 2 of Terminal Widgets Example 3 of Terminal Widgets

For all examples see Examples.


🧩 6. Contributing

Help the project grow: create an issue or pull request (On GitHub)!


📜 7. License

See License

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

twidgets-2.0.0.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

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

twidgets-2.0.0-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file twidgets-2.0.0.tar.gz.

File metadata

  • Download URL: twidgets-2.0.0.tar.gz
  • Upload date:
  • Size: 36.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for twidgets-2.0.0.tar.gz
Algorithm Hash digest
SHA256 391f4812f2948e3894cb6a64d2effdc8f312588c6f728ba7027a3828c4a40dea
MD5 eb31c5bba79ad3ec23b0b80b4311216b
BLAKE2b-256 d5cb675b4a1481ad440e6a0a5e4a4cd13e9425d9bccc229f02ae799c61596df9

See more details on using hashes here.

Provenance

The following attestation bundles were made for twidgets-2.0.0.tar.gz:

Publisher: publish.yml on IceWizard7/terminal-widgets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file twidgets-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: twidgets-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 44.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for twidgets-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f3b330cad16cbece12f839805a83175fe2cf7eb26c69816e07cd87222d19c49
MD5 ad0aa8b02979b2c28619b943e7b3652e
BLAKE2b-256 37f9c9b4e6a2041f7cbcae630701bfac9485697093f1e283417c3afa647ce4c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for twidgets-2.0.0-py3-none-any.whl:

Publisher: publish.yml on IceWizard7/terminal-widgets

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