wijjit.core.event_loop.EventLoop

class wijjit.core.event_loop.EventLoop(app, executor=None)[source]

Main event loop for Wijjit applications.

The event loop handles: - Input reading from keyboard and mouse - Terminal resize detection - Animation frame advancement - Notification expiry checks - Event dispatching to handlers - Rendering orchestration

Parameters:
  • app (Wijjit) – Reference to the main application

  • executor (ThreadPoolExecutor, optional) – Thread pool for running sync handlers off the event loop thread. If None, sync handlers run directly on the event loop (blocking).

Variables:
  • app (Wijjit) – Application reference

  • running (bool) – Whether the event loop is currently running

  • executor (ThreadPoolExecutor or None) – Thread pool executor for sync handlers (if configured)

__init__(app, executor=None)[source]

Initialize the event loop.

Parameters:
  • app (Wijjit) – Reference to the main application

  • executor (ThreadPoolExecutor, optional) – Thread pool for running sync handlers. If None, sync handlers run directly on event loop thread (may block).

Return type:

None

Methods

__init__(app[, executor])

Initialize the event loop.

run()

Run the main event loop.

run_async()

Run the main async event loop.

stop()

Stop the event loop.

run()[source]

Run the main event loop.

This is the entry point for the application. It wraps the async event loop for backward compatibility with synchronous code.

The loop continues until quit() is called or the user presses Ctrl+C.

Raises:

RuntimeError – If no views are registered

Return type:

None

async run_async()[source]

Run the main async event loop.

This method enters the main event loop which: 1. Renders initial view 2. Loops: read input -> dispatch events -> re-render if needed 3. Exits on quit() or Ctrl+C

The loop continues until quit() is called or the user presses Ctrl+C.

Raises:

RuntimeError – If no views are registered

Return type:

None

stop()[source]

Stop the event loop.

Sets the running flag to False which will cause the event loop to exit after the current iteration completes.

Return type:

None