API Reference¶
Module structure¶
libui
├── core # C extension — low-level bindings to libui-ng
├── loop # Threading model — run(), invoke_on_main(), etc.
├── state # Reactive state — State, Computed, ListState
├── node # Node base class, BuildContext, stretchy
├── declarative # High-level API — re-exports everything below
│ └── app # App, Window, MenuDef, MenuItem, etc.
└── widgets # Individual widget node implementations
├── containers # VBox, HBox, Group, Form, Tab, Grid, GridCell
├── button # Button
├── label # Label
├── entry # Entry, MultilineEntry
├── checkbox # Checkbox
├── slider # Slider
├── spinbox # Spinbox
├── progressbar # ProgressBar
├── combobox # Combobox, EditableCombobox
├── radiobuttons # RadioButtons
├── pickers # ColorButton, FontButton, DateTimePicker
├── separator # Separator
├── draw # DrawArea, ScrollingDrawArea
└── table # DataTable, column descriptors
libui (top-level)¶
The top-level libui module re-exports thread-safe proxy classes for the imperative API:
import libui
window = libui.Window("Title", 400, 300)
button = libui.Button("Click")
label = libui.Label("Hello")
# ... etc
These are proxy wrappers around libui.core objects that automatically dispatch mutations to the main thread.
Functions¶
libui.loop.run()— Start the two-thread architecture and run your async functionlibui.loop.quit()— Stop the UI event loop (thread-safe)
libui.declarative¶
The declarative module provides all building blocks for the recommended API:
from libui.declarative import App, Window, VBox, Label, Button, State
See the Widget Reference for complete widget documentation.
Exports¶
Containers: VBox, HBox, Group, Form, Tab, Grid, GridCell
Controls: Label, Button, Entry, MultilineEntry, Checkbox, Slider, Spinbox, ProgressBar, Combobox, EditableCombobox, RadioButtons, ColorButton, FontButton, DateTimePicker, Separator
Drawing: DrawArea, ScrollingDrawArea
Tables: DataTable, ListState, TextColumn, CheckboxColumn, CheckboxTextColumn, ProgressColumn, ButtonColumn, ImageColumn, ImageTextColumn
Menus: MenuDef, MenuItem, CheckMenuItem, MenuSeparator, QuitItem, PreferencesItem, AboutItem
State: State, Computed, ListState
Helpers: stretchy()
libui.state¶
State¶
Method |
Description |
|---|---|
Get current value |
|
Set value and notify |
|
Apply |
|
Add subscriber, returns unsubscribe function |
|
Remove subscriber |
|
Create |
Computed¶
Method |
Description |
|---|---|
Get current computed value |
|
Add subscriber |
|
Remove subscriber |
|
Chain another derived value |
ListState¶
Method |
Description |
|---|---|
Add item, notify with |
|
Remove item, notify with |
|
Add subscriber for change events |
libui.loop¶
Function |
Description |
|---|---|
Start UI + asyncio event loops |
|
Stop the event loop |
|
Run |
|
Run |
libui.core¶
The C extension module. Provides direct access to libui-ng widgets without thread-safety wrappers. All functions (except queue_main and quit) must be called from the main thread.
Functions¶
Function |
Thread-safe |
Description |
|---|---|---|
No |
Initialize libui |
|
No |
Clean up libui |
|
No |
Run the main event loop (blocking) |
|
No |
Enable stepping mode |
|
No |
Process one event (requires |
|
Yes |
Stop the event loop |
|
Yes |
Enqueue function for main thread |
|
Yes |
Check if on main thread |
|
No |
Register quit handler |
Dialogs¶
Function |
Description |
|---|---|
Show file open dialog, returns path or |
|
Show folder open dialog, returns path or |
|
Show file save dialog, returns path or |
|
Show info message box |
|
Show error message box |
Text attributes¶
Function |
Description |
|---|---|
Font family attribute |
|
Font size attribute |
|
Font weight attribute |
|
Italic style attribute |
|
Font stretch attribute |
|
Text color attribute |
|
Background color attribute |
|
Underline style attribute |
|
Underline color attribute |
|
OpenType features attribute |
Types¶
Type |
Description |
|---|---|
Top-level window |
|
Clickable button |
|
Text label |
|
Vertical/horizontal container |
|
Text input |
|
Toggle checkbox |
|
Dropdown selector |
|
Editable dropdown |
|
Radio button group |
|
Tabbed container |
|
Titled container |
|
Label + control pairs |
|
Grid layout |
|
Numeric spinner |
|
Range slider |
|
Progress indicator |
|
Visual divider |
|
Multi-line text editor |
|
Date/time picker |
|
Color picker |
|
Font picker |
|
Menu bar entry |
|
Menu item |
|
Geometry path |
|
Fill/stroke brush |
|
Stroke parameters |
|
Affine transform |
|
Formatted text layout |
|
Rich text with attributes |
|
OpenType feature set |
|
Image for tables |
|
Table data model |
|
Data table widget |
|
Custom drawing surface |
|
Scrollable drawing surface |
Full API docs¶
libui.core— C Extensionlibui.state— Reactive Statelibui.loop— Threading & Event Looplibui.node— Node Base & Build Infrastructurelibui.declarative— Declarative APIStateComputedListStateBuildContextNodestretchy()VBoxHBoxGroupFormTabGridGridCellLabelButtonEntryCheckboxSliderSpinboxProgressBarComboboxRadioButtonsEditableComboboxMultilineEntryColorButtonFontButtonDateTimePickerSeparatorDrawAreaScrollingDrawAreaDataTableTextColumnCheckboxColumnCheckboxTextColumnProgressColumnButtonColumnImageColumnImageTextColumnAppWindowMenuDefMenuItemCheckMenuItemMenuSeparatorQuitItemPreferencesItemAboutItem- App & Window
libui.widgets— Widget NodesVBoxHBoxGroupFormTabGridGridCellLabelButtonEntryCheckboxSliderSpinboxProgressBarComboboxRadioButtonsEditableComboboxMultilineEntryColorButtonFontButtonDateTimePickerSeparatorDrawAreaScrollingDrawAreaDataTableTextColumnCheckboxColumnCheckboxTextColumnProgressColumnButtonColumnImageColumnImageTextColumn- Containers
- Button
- Label
- Entry
- Checkbox
- Slider
- Spinbox
- ProgressBar
- Combobox
- RadioButtons
- Pickers
- Separator
- Drawing
- Table