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 keyget(key)- Get a menu item by keyadd_separator()- Add a menu separatorset_title(title)- Set the status bar titleset_icon(icon, template=True)- Set the status bar iconupdate()- 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 addalignment- 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 addalignment- 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 endextend(views)- Add multiple viewsinsert(index, view)- Insert view at indexremove(view)- Remove a viewclear()- Remove all views
Alignment Constants:
NSLayoutAttributeLeading- Left alignment (horizontal) or top (vertical)NSLayoutAttributeCenterX- Center horizontallyNSLayoutAttributeCenterY- Center verticallyNSLayoutAttributeTrailing- Right alignment (horizontal) or bottom (vertical)