API Reference

Application

Application and window management, JS bridge, and file dialogs.

class iskg.app.Application(title: str = 'ISKG App', width: int = 800, height: int = 600, scanlines: bool = True, vignette: bool = True, theme: str = 'ifaz', debug: bool = False)[source]

Bases: object

Main application entry point.

Creates a native window via pywebview, renders all widgets as HTML/CSS/JS, and manages the JS bridge for event handling.

Usage:

app = Application("My App", 800, 600)
label = Label(text="Hello")
app.add(label)
app.run()

Pass debug=True to log JavaScript errors to stderr:

app = Application(debug=True)
add(widget: Widget) Widget[source]

Register a root-level widget with the application.

Widgets must be added to the app before run() is called.

alert(message: str) None[source]

Show a browser-style alert dialog.

color_dialog(title: str = 'Choose Color', initial_color: str = '#000000') str | None[source]

Open a color picker dialog.

Uses GTK on Linux, falls back to a browser <input type="color"> on Windows/macOS.

Returns a hex string (e.g. "#ff8800") or None.

confirm(message: str) None[source]

Show a browser-style confirm dialog.

current_theme() str[source]

Return the name of the currently active theme.

property debug: bool
execute_js(js_code: str) Application[source]

Execute arbitrary JavaScript in the webview window.

file_dialog(dialog_type: str = 'open', directory: str = '', file_types: list[str] | None = None, allow_multiple: bool = False) Any | None[source]

Open a native OS file dialog.

Uses GTK directly (same toolkit as pywebview underneath) with explicit dialog sizing. Falls back to pywebview’s built-in dialog.

Parameters:
  • dialog_type"open", "save", or "folder".

  • directory – starting directory path.

  • file_types – list of extensions like ["*.txt", "*.py"].

  • allow_multiple – allow multiple file selection (open only).

font_dialog(title: str = 'Choose Font', initial_font: str = '') dict[str, Any] | None[source]

Open a font picker dialog.

Uses GTK on Linux, falls back to a browser prompt on Windows/macOS.

Returns a dict with keys family, size, weight, style, or None.

geometry(x: int | None = None, y: int | None = None, w: int | None = None, h: int | None = None) tuple[int, int, int, int][source]

Get or set the window position and size.

get_clipboard() str[source]

Read text from the system clipboard (requires pyperclip).

on_close(callback: Callable) None[source]

Register a callback to call when the window is closed.

quit() None[source]

Close the application window and exit the main loop.

register_theme(name: str, overrides: dict[str, str]) Application[source]

Register a new theme for runtime use.

Parameters:
  • name – unique theme name (e.g. "mytheme").

  • overrides – dict of CSS custom properties, e.g. {"--bg-primary": "#000", "--text": "#fff"}.

remove(widget: Widget) None[source]

Unregister a root-level widget.

run(extra_js: str = '') None[source]

Open the window and start the application main loop.

Blocks until the window is closed. Redirects GTK stderr warnings to /dev/null during execution.

Parameters:

extra_js – additional JavaScript to execute on startup (e.g. tooltip init code).

set_clipboard(text: str) None[source]

Copy text to the system clipboard (requires pyperclip).

set_theme(name: str) Application[source]

Switch the UI theme at runtime.

Parameters:

name – one of "ifaz", "cold", "warm", "night", or a custom name previously registered via register_theme().

title(text: str | None = None) str[source]

Get or set the window title.

winfo_screendpi() int[source]

Return the screen DPI (approximate, requires a running window).

winfo_screenheight() int[source]

Return the screen height in pixels (requires a running window).

winfo_screenwidth() int[source]

Return the screen width in pixels (requires a running window).

iskg.app.Window

alias of Application

Base Widget

Base Widget class with layout engines (pack/grid/place), event bindings, style rendering, and widget tree management.

class iskg.base.Widget(parent: Widget | None = None, **kwargs: Any)[source]

Bases: object

Base class for all ISKG widgets.

Manages widget identity, parent-child tree, layout configuration, style rendering, event bindings, and bridge communication with the JavaScript frontend.

Every concrete widget (Button, Label, Frame, etc.) inherits from this class.

add(child: Widget) None[source]

Add a child widget to this widget’s children list.

after(ms: int, callback: Callable) _Timer[source]

Schedule a function to run after ms milliseconds.

Parameters:
  • ms – delay in milliseconds.

  • callback – function to call (no arguments).

Returns:

A _Timer with .cancel() and .running.

after_cancel(timer_id: str) None[source]

Cancel a timer by its string ID (legacy).

property app: Any

The Application instance this widget belongs to, or None.

bind(event: str, callback: Callable) None[source]

Bind a callback to an event.

Supports standard bridge events ("click", "change", etc.), tkinter-style key events ("<KeyPress-a>", "<KeyRelease-Return>", "<Control-c>", "<Key>"), and virtual events ("<<CustomEvent>>").

Key event callbacks receive a dict with key, code, ctrl, alt, shift.

cget(key: str) Any[source]

Get a widget configuration value by key.

config(**kwargs: Any) Widget[source]

Configure widget properties.

Accepts any keyword argument; underscores in keys are converted to hyphens for CSS. Common keys: fg, bg, font_size, padding, border_color, opacity, etc.

Also accepts state ("normal", "disabled", "readonly"), visible (bool), textvariable, and variable which are handled specially.

property cursor: str
destroy() None[source]

Destroy this widget and all its children.

event_generate(event: str, data: Any = None) bool[source]

Generate a virtual event that bubbles up the parent chain.

Parameters:
  • event – event name (e.g. "<<Custom>>", "click", "change").

  • data – optional data passed to the callback.

Returns:

True if propagation should stop (callback returned "break").

focus() None[source]

Move keyboard focus to this widget.

focus_next() None[source]

Move focus to the next widget in tab order.

focus_prev() None[source]

Move focus to the previous widget in tab order.

focus_set() None

Move keyboard focus to this widget.

grid(row: int = 0, column: int = 0, rowspan: int = 1, columnspan: int = 1, sticky: str = '', padx: int = 0, pady: int = 0) Widget[source]

Arrange this widget using grid layout.

Parameters:
  • row – row index (0-based).

  • column – column index (0-based).

  • rowspan – number of rows to span.

  • columnspan – number of columns to span.

  • sticky – combination of "n", "s", "e", "w", or "c" for center.

  • padx – horizontal padding.

  • pady – vertical padding.

To control row/column weights and minimum sizes, use grid_columnconfigure() and grid_rowconfigure() on the parent Frame.

grid_forget() None[source]

Remove from grid layout (position lost). Call grid() with new parameters to re-display.

grid_remove() None[source]

Remove from grid layout, remembering position. Call grid() with the same parameters to restore.

property height: int | None
hide() None[source]

Hide this widget.

pack(side: str = 'top', fill: str = 'none', expand: bool = False, padx: int = 0, pady: int = 0, anchor: str = 'nw') Widget[source]

Arrange this widget using pack layout.

Parameters:
  • side"top", "left", "bottom", or "right".

  • fill"none", "x", "y", or "both".

  • expand – whether to take extra space.

  • padx – horizontal padding in pixels.

  • pady – vertical padding in pixels.

  • anchor"nw", "n", "ne", "w", "e", "sw", "s", "se".

pack_forget() None

Remove from grid layout (position lost). Call grid() with new parameters to re-display.

property parent: Widget | None

Parent widget, or None if this is a root widget.

place(x: int = 0, y: int = 0, width: int | None = None, height: int | None = None, anchor: str = 'nw') Widget[source]

Position this widget at absolute coordinates.

Parameters:
  • x – left offset in pixels.

  • y – top offset in pixels.

  • width – explicit width in pixels, or None for auto.

  • height – explicit height in pixels, or None for auto.

  • anchor"nw", "n", "ne", "w", "e", "sw", "s", "se".

remove(child: Widget) None[source]

Remove a child widget from this widget’s children list.

show() None[source]

Show this widget.

property state: str

Get the widget state ("normal", "disabled", "readonly").

property takefocus: bool

Whether this widget can receive keyboard focus. Default True for interactive widgets (Button, Entry, etc.), False for containers.

property tooltip: str

Get/set the hover tooltip text for this widget.

unbind(event: str) None[source]

Remove a previously bound event callback.

update() None[source]

Force a sync update of this widget’s rendering.

property visible: bool

Whether the widget is visible.

property widget_id: str

Unique identifier for this widget instance.

property width: int | None

Widget Controls

class iskg.widgets._controls.Button(parent: Widget | None = None, text: str = '', command: Callable | None = None, **kwargs: Any)[source]

Bases: Widget

A clickable push button with IFAZ tactical styling.

property text: str
class iskg.widgets._controls.CheckBox(parent: Widget | None = None, text: str = '', checked: bool = False, command: Callable | None = None, **kwargs: Any)[source]

Bases: Widget

A toggleable check box with label.

property checked: bool
property text: str
class iskg.widgets._controls.ComboBox(parent: Widget | None = None, values: list[str] | None = None, current: int = 0, command: Callable | None = None, editable: bool = False, **kwargs: Any)[source]

Bases: Widget

A dropdown select menu.

property current: int
property editable: bool
property value: str
class iskg.widgets._controls.Entry(parent: Widget | None = None, text: str = '', justify: str = '', maxlength: int | None = None, **kwargs: Any)[source]

Bases: Widget

A single-line text input field.

property justify: str
property maxlength: int | None
property text: str
class iskg.widgets._controls.RadioButton(parent: Widget | None = None, text: str = '', group: str = 'default', command: Callable | None = None, value: str = '', variable: Any = None, **kwargs: Any)[source]

Bases: Widget

A radio button for single-selection within a group.

property selected: bool
property text: str
property value: Any
class iskg.widgets._controls.Scale(parent: Widget | None = None, value: float = 0.5, command: Callable | None = None, from_: float = 0.0, to: float = 1.0, orient: str = 'horizontal', **kwargs: Any)[source]

Bases: Slider

A range slider with min/max labels.

class iskg.widgets._controls.Slider(parent: Widget | None = None, value: float = 50, min_value: float = 0, max_value: float = 100, command: Callable | None = None, from_: float = 0, to: float = 100, orient: str = 'horizontal', **kwargs: Any)[source]

Bases: Widget

A horizontal range slider.

property value: float
class iskg.widgets._controls.SpinBox(parent: Widget | None = None, value: int = 0, min_value: int = 0, max_value: int = 100, step: int = 1, command: Callable | None = None, from_: int = 0, to: int = 100, **kwargs: Any)[source]

Bases: Widget

A numeric stepper with up/down buttons.

property value: int
class iskg.widgets._controls.ToggleSwitch(parent: Widget | None = None, text: str = '', active: bool = False, command: Callable | None = None, checked: bool = False, **kwargs: Any)[source]

Bases: Widget

A toggle switch akin to a checkbox with slider appearance.

property checked: bool

Widget Display

class iskg.widgets._display.IconLabel(parent: Widget | None = None, text: str = '', icon: str = '', icon_size: int = 14, **kwargs: Any)[source]

Bases: Widget

A label with an inline icon.

class iskg.widgets._display.ImageBox(parent: Widget | None = None, src: str = '', width: int = 100, height: int = 100, fit: str = 'contain', **kwargs: Any)[source]

Bases: Widget

A widget that displays an image.

class iskg.widgets._display.IndicatorLED(parent: Widget | None = None, color: str = 'green', size: int = 8, active: bool = True, label: str = '', **kwargs: Any)[source]

Bases: Widget

A small colored indicator light.

property active: bool
class iskg.widgets._display.LEDDisplay(parent: Widget | None = None, value: Any = 0, digits: int = 4, color: str = 'green', label: str = '', height: int = 32, **kwargs: Any)[source]

Bases: Widget

A seven-segment LED-style digital display.

property value: Any
class iskg.widgets._display.Label(parent: Widget | None = None, text: str = '', wraplength: int | None = None, anchor: str = '', justify: str = '', **kwargs: Any)[source]

Bases: Widget

A static text label.

property anchor: str
property justify: str
property text: str
property wraplength: int | None
class iskg.widgets._display.ProgressBar(parent: Widget | None = None, value: float = 0, max_: int = 100, **kwargs: Any)[source]

Bases: Widget

A clickable progress bar widget.

Supports click-to-set-value, command callbacks, bind("change", cb), and variable binding. Use max_ to set the range maximum.

Usage:

pb = ProgressBar(value=50, max_=100, command=lambda: print("clicked"))
property value: float
class iskg.widgets._display.RadialGauge(parent: Widget | None = None, from_: int = 0, to: int = 100, value: float = 50, size: int = 100, label: str = '', units: str = '', **kwargs: Any)[source]

Bases: Widget

A radial gauge dial for displaying values.

property value: float
class iskg.widgets._display.StatusBar(parent: Widget | None = None, sections: list | None = None, **kwargs: Any)[source]

Bases: Widget

A status bar with multiple sections.

Widget Containers

class iskg.widgets._containers.Frame(parent: Widget | None = None, text: str = '', **kwargs: Any)[source]

Bases: Widget

A rectangular container widget for grouping children.

grid_columnconfigure(column: int, weight: float = 0, minsize: int = 0) None[source]

Configure a grid column’s weight and minimum size.

Parameters:
  • column – column index (0-based).

  • weight – relative weight for distributing extra space (0 = auto).

  • minsize – minimum column width in pixels (0 = none).

When both weight and minsize are 0 the column is removed from the explicit config and treated as auto.

grid_rowconfigure(row: int, weight: float = 0, minsize: int = 0) None[source]

Configure a grid row’s weight and minimum size.

Parameters:
  • row – row index (0-based).

  • weight – relative weight for distributing extra space (0 = auto).

  • minsize – minimum row height in pixels (0 = none).

pack_propagate(flag: bool) None[source]
class iskg.widgets._containers.Notebook(parent: Widget | None = None, **kwargs: Any)[source]

Bases: Widget

A tabbed container widget.

add_tab(title: str, widget: Widget) Widget[source]
class iskg.widgets._containers.PanedWindow(parent: Widget | None = None, orient: str = 'horizontal', sash_pos: float = 0.5, minsize: int = 30, **kwargs: Any)[source]

Bases: Widget

A container with two resizable panes separated by a draggable divider.

Parameters:
  • parent – parent widget.

  • orient"horizontal" (left/right panes) or "vertical" (top/bottom).

  • sash_pos – initial divider position as fraction (0.0–1.0, default 0.5).

  • minsize – minimum pane size in pixels (default 30).

sash_pos(pos: float) None[source]
class iskg.widgets._containers.ScrollBar(parent: Widget | None = None, orient: str = 'vertical', value: float = 0, **kwargs: Any)[source]

Bases: Widget

A scrollbar widget for scrolling content.

class iskg.widgets._containers.ScrolledFrame(parent: Widget | None = None, width: int | None = None, height: int | None = None, scroll: str = 'vertical', autoscroll: bool = False, **kwargs: Any)[source]

Bases: Frame

A frame with scrollbars when content overflows.

Parameters:
  • parent – parent widget.

  • width – viewport width in pixels (auto if omitted).

  • height – viewport height in pixels (auto if omitted).

  • scroll"vertical" (default), "horizontal", or "both".

  • autoscroll – if True, auto-scrolls to bottom on content change (useful for log viewers).

class iskg.widgets._containers.Separator(parent: Widget | None = None, orient: str = 'horizontal', **kwargs: Any)[source]

Bases: Widget

A horizontal or vertical visual separator line.

class iskg.widgets._containers.Spacer(parent: Widget | None = None, width: int = 0, height: int = 0, expand: bool = False, **kwargs: Any)[source]

Bases: Widget

An invisible spacer widget for layout.

Widget Text

class iskg.widgets._text.RichText(parent: Widget | None = None, text: str = '', height: int = 150, show_toolbar: bool = True, **kwargs: Any)[source]

Bases: Widget

A rich text editor with formatting toolbar.

class iskg.widgets._text.Text(parent: Widget | None = None, text: str = '', **kwargs: Any)[source]

Bases: Widget

A multi-line text input area.

append(text: str) None[source]
clear() None[source]
property text: str

Widget Data

class iskg.widgets._data.DataGrid(parent: Widget | None = None, columns: list[str] | None = None, rows: list[list[str]] | None = None, width: int = 300, height: int = 200, **kwargs: Any)[source]

Bases: Widget

A sortable data table with columns and rows.

property rows: list[list[str]]
class iskg.widgets._data.DropTarget(parent: Widget | None = None, text: str = 'Drop files here', width: int = 200, height: int = 100, **kwargs: Any)[source]

Bases: Widget

A drag-and-drop target area.

class iskg.widgets._data.ListBox(parent: Widget | None = None, items: list[str] | None = None, command: Callable | None = None, **kwargs: Any)[source]

Bases: Widget

A selectable list of items.

append(item: str) None[source]
clear() None[source]
delete(idx: int) None[source]
insert(idx: int, item: str) None[source]
property items: list[str]
class iskg.widgets._data.TreeView(parent: Widget | None = None, items: list | None = None, width: int = 200, height: int = 200, **kwargs: Any)[source]

Bases: Widget

A hierarchical tree view widget.

Widget Canvas

class iskg.widgets._canvas.Canvas(parent: Widget | None = None, width: int = 300, height: int = 200, **kwargs: Any)[source]

Bases: Widget

A drawing surface for shapes and text.

clear() None[source]
create_arc(x1: int, y1: int, x2: int, y2: int, start: int = 0, extent: int = 90, **kwargs: Any) None[source]
create_line(x1: int, y1: int, x2: int, y2: int, **kwargs: Any) None[source]
create_oval(x1: int, y1: int, x2: int, y2: int, **kwargs: Any) None[source]
create_rectangle(x1: int, y1: int, x2: int, y2: int, **kwargs: Any) None[source]
create_text(x: int, y: int, text: str = '', **kwargs: Any) None[source]
class iskg.widgets._canvas.Knob(parent: Widget | None = None, from_: int = 0, to: int = 100, value: float = 0, size: int = 60, color: str = 'cyan', show_value: bool = True, **kwargs: Any)[source]

Bases: Widget

A rotary knob control for adjusting values.

property value: float

Widget Menus

class iskg.widgets._menus.Menu(text: str = '')[source]

Bases: object

A dropdown menu for the main menu bar.

add_item(text: str, command: Callable | None = None, shortcut: str = '', icon: str = '') MenuItem[source]
add_menu(text: str) Menu[source]
add_separator() None[source]
class iskg.widgets._menus.MenuBar(parent: Widget | None = None, **kwargs: Any)[source]

Bases: Widget

A main menu bar with dropdown menus.

add_menu(text: str) Menu[source]
class iskg.widgets._menus.MenuItem(text: str, command: Callable | None = None, shortcut: str = '', icon: str = '')[source]

Bases: object

An item within a Menu.

Widget Dialogs

class iskg.widgets._dialogs.FileDialog[source]

Bases: object

Static methods for native file open/save dialogs.

static open_file(app: Any, title: str = 'Open', directory: str = '', file_types: list[str] | None = None, multiple: bool = False) Any[source]
static open_folder(app: Any, title: str = 'Select Folder', directory: str = '') Any[source]
static save_file(app: Any, title: str = 'Save As', directory: str = '', file_types: list[str] | None = None) Any[source]
class iskg.widgets._dialogs.MessageDialog(parent: Widget | None = None, title: str = '', text: str = '', buttons: list[str] | None = None, callback: Callable[[str], None] | None = None, **kwargs: Any)[source]

Bases: Widget

A message box overlay (info/warning/error/question).

Shows an HTML overlay within the app window. Pass callback to receive the clicked button label.

show(app: Any = None) None[source]

Show this widget.

iskg.widgets._dialogs.showerror(title: str = '', text: str = '', parent: Widget | None = None, callback: Callable[[str], None] | None = None) MessageDialog[source]

Show an error message box (HTML overlay).

iskg.widgets._dialogs.showinfo(title: str = '', text: str = '', parent: Widget | None = None, callback: Callable[[str], None] | None = None) MessageDialog[source]

Show an info message box (HTML overlay).

iskg.widgets._dialogs.showquestion(title: str = '', text: str = '', parent: Widget | None = None, callback: Callable[[str], None] | None = None) MessageDialog[source]

Show a question dialog with Yes/No buttons (HTML overlay).

iskg.widgets._dialogs.showwarning(title: str = '', text: str = '', parent: Widget | None = None, callback: Callable[[str], None] | None = None) MessageDialog[source]

Show a warning message box (HTML overlay).

Widget Misc

class iskg.widgets._misc.Tooltip(parent: Widget | None = None, text: str = '', delay: int = 500, **kwargs: Any)[source]

Bases: Widget

A hover tooltip that displays text near a widget.

attach(target_id: str) str[source]

Template & Bridge

HTML page builder and JS bridge for ISKG widgets.

iskg.template.build_html(root_widgets: list[Any], ifaz_css: str, extra_js: str = '', theme_name: str = 'ifaz') str[source]

Theme

Themes

Named theme definitions for ISKG.

Each theme is a dict of CSS custom property overrides applied on top of the default IFAZ style sheet (iskg.theme.IFAZ_CSS).

Available themes: ifaz, desert, infinity, cyberdusk, light, dracula, nord, gruvbox, monokai, catppuccin.

Usage:

from iskg.themes import THEMES, available_themes, theme_js

# List available themes
available_themes()  # -> ["ifaz", "desert", ...]

# Apply theme at runtime
app.set_theme("dracula")

# Or get JS to apply manually
js = theme_js("nord")
app.execute_js(js)
iskg.themes.available_themes() list[str][source]

Return the list of registered theme names.

iskg.themes.resolve_theme(name: str) dict[str, str][source]

Return the theme dict for name, falling back to "ifaz".

iskg.themes.theme_css(name: str) str[source]

Return a CSS :root block for the named theme (for initial render).

iskg.themes.theme_js(name: str) str[source]

Return a JavaScript snippet that applies the named theme in the browser.

Call execute_js() on the application window to apply:

app.execute_js(theme_js("cold"))

Fonts

Embedded fonts (SIL OFL) as base64 woff2 data.

No external CDN required — all fonts are compiled directly into the package as base64-encoded @font-face CSS.

Available fonts and their CSS variables:

Usage:

# Font CSS is automatically included in the page. Use CSS variables:
# var(--font-sans), var(--font-mono), var(--font-rounded), etc.
# Or fall back to system fonts by not setting a custom font:

widget.config(font="bold 14px var(--font-display)")

To use system fonts instead, override the CSS variable:

app._eval_js("document.documentElement.style.setProperty('--font-sans', 'Arial, sans-serif')")
iskg.fonts.font_css() str[source]

Return @font-face CSS rules for all embedded fonts.