wijjit.core.render_context.RenderContext

class wijjit.core.render_context.RenderContext(layout_context, template_context, focused_id=None, radiogroup_stack=<factory>, menu_stack=<factory>, item_stack=<factory>, frame_counter=0, overlays=<factory>, statusbar=None)[source]

Consolidated rendering context for template processing.

This class holds all state needed during template rendering, replacing the scattered _wijjit_* globals that were stored in Jinja2’s environment.

Parameters:
  • layout_context (LayoutContext) – The layout context for building VNode trees

  • template_context (dict) – Template variables including ‘state’

  • focused_id (str | None)

  • radiogroup_stack (list[str])

  • menu_stack (list[list[MenuItem]])

  • item_stack (list[list[Any]])

  • frame_counter (int)

  • overlays (list[dict[str, Any]])

  • statusbar (Any)

Variables:
  • layout_context (LayoutContext) – Layout tree building context

  • template_context (dict) – Template variables (contains ‘state’, etc.)

  • focused_id (str or None) – ID of the currently focused element

  • radiogroup_stack (list of str) – Stack of active radio group names (for nesting)

  • menu_stack (list of list of MenuItem) – Stack of menu item lists being built

  • item_stack (list of list) – Stack of generic item lists being collected by container tags

  • frame_counter (int) – Counter for auto-generating frame IDs

  • overlays (list) – List of overlay info dicts for dialogs/menus

  • statusbar (Element or None) – StatusBar element if present

__init__(layout_context, template_context, focused_id=None, radiogroup_stack=<factory>, menu_stack=<factory>, item_stack=<factory>, frame_counter=0, overlays=<factory>, statusbar=None)
Parameters:
  • layout_context (LayoutContext)

  • template_context (dict[str, Any])

  • focused_id (str | None)

  • radiogroup_stack (list[str])

  • menu_stack (list[list[MenuItem]])

  • item_stack (list[list[Any]])

  • frame_counter (int)

  • overlays (list[dict[str, Any]])

  • statusbar (Any)

Return type:

None

Methods

__init__(layout_context, template_context[, ...])

add_overlay(overlay_info)

Add an overlay info dict.

generate_frame_id()

Generate a unique frame ID.

pop_items()

Pop and return the current generic item list.

pop_menu()

Pop and return the current menu items list.

pop_radiogroup()

Pop and return the current radio group name.

push_items()

Push a new generic item list onto the item stack.

push_menu()

Push a new menu items list onto the stack.

push_radiogroup(name)

Push a radio group name onto the stack.

Attributes

current_items

Get the current generic item list without popping.

current_menu

Get the current menu items list without popping.

current_radiogroup

Get the current radio group name without popping.

focused_id

frame_counter

state

Get the application state dict from template context.

statusbar

layout_context

template_context

radiogroup_stack

menu_stack

item_stack

overlays

layout_context: LayoutContext
template_context: dict[str, Any]
focused_id: str | None = None
radiogroup_stack: list[str]
menu_stack: list[list[MenuItem]]
item_stack: list[list[Any]]
frame_counter: int = 0
overlays: list[dict[str, Any]]
statusbar: Any = None
property state: dict[str, Any]

Get the application state dict from template context.

Returns:

Application state, or empty dict if not present

Return type:

dict

generate_frame_id()[source]

Generate a unique frame ID.

Returns:

Generated ID like ‘frame_1’

Return type:

str

push_radiogroup(name)[source]

Push a radio group name onto the stack.

Parameters:

name (str) – Radio group name

Return type:

None

pop_radiogroup()[source]

Pop and return the current radio group name.

Returns:

The popped radio group name, or None if stack is empty

Return type:

str or None

property current_radiogroup: str | None

Get the current radio group name without popping.

Returns:

Current radio group name, or None if not in a group

Return type:

str or None

push_menu()[source]

Push a new menu items list onto the stack.

Returns:

The new menu items list (to be populated by menuitem tags)

Return type:

list

pop_menu()[source]

Pop and return the current menu items list.

Returns:

The popped menu items list, or None if stack is empty

Return type:

list or None

property current_menu: list[MenuItem] | None

Get the current menu items list without popping.

Returns:

Current menu items list, or None if not building a menu

Return type:

list or None

push_items()[source]

Push a new generic item list onto the item stack.

Used by list-like elements (select, tree) to collect items declared via nested child tags (selectitem/treeitem). Tree nesting pushes an additional list per level for child items.

Returns:

The new item list (to be populated by child item tags).

Return type:

list

pop_items()[source]

Pop and return the current generic item list.

Returns:

The popped item list, or None if the stack is empty.

Return type:

list or None

property current_items: list[Any] | None

Get the current generic item list without popping.

Returns:

Current item list, or None if not building one.

Return type:

list or None

add_overlay(overlay_info)[source]

Add an overlay info dict.

Parameters:

overlay_info (dict) – Overlay configuration dict

Return type:

None