Core Module

The core module provides the main classes and functions for building stackit applications.

StackApp

The main application class for managing status bar applications.

app = stackit.StackApp(title="My App", icon="🎯")

Methods:

  • add(menu_item, key=None) - Add a menu item (key is optional and auto-generated if not provided)

  • remove(key) - Remove a menu item by key

  • get(key) - Get a menu item by key

  • add_separator() - Add a menu separator

  • set_title(title) - Set the status bar title

  • set_icon(icon, template=True) - Set the status bar icon

  • update() - Force the menu to update and redraw (call after updating layouts)

  • run() - Start the application event loop (automatically adds Quit button)

Layout Functions

Standalone functions for creating layouts.

hstack()

Create a horizontal stack view.

layout = stackit.hstack([
    stackit.label("Status:"),
    stackit.spacer(),
    stackit.label("Active", color="green")
], spacing=8.0)

Parameters:

  • controls - Optional list of controls to add

  • alignment - Optional alignment (NSLayoutAttribute constant)

  • spacing - Spacing between controls in points (default: 8.0)

Returns: StackView configured for horizontal layout

vstack()

Create a vertical stack view.

layout = stackit.vstack([
    stackit.label("Title", bold=True),
    stackit.progress_bar(value=0.75),
    stackit.button("Submit", callback=my_callback)
], spacing=12.0)

Parameters:

  • controls - Optional list of controls to add

  • alignment - Optional alignment (NSLayoutAttribute constant)

  • spacing - Spacing between controls in points (default: 8.0)

Returns: StackView configured for vertical layout

StackView

Container for arranging UI elements in horizontal or vertical layouts. Created by hstack() and vstack() functions.

# Create stacks
hstack = stackit.hstack(spacing=8)
vstack = stackit.vstack(spacing=4)

# Dynamically add controls
vstack.append(stackit.label("New item"))
vstack.extend([label1, label2, label3])

List-like Methods:

  • append(view) - Add a view to the end

  • extend(views) - Add multiple views

  • insert(index, view) - Insert view at index

  • remove(view) - Remove a view

  • clear() - Remove all views

Alignment Constants:

  • NSLayoutAttributeLeading - Left alignment (horizontal) or top (vertical)

  • NSLayoutAttributeCenterX - Center horizontally

  • NSLayoutAttributeCenterY - Center vertically

  • NSLayoutAttributeTrailing - Right alignment (horizontal) or bottom (vertical)