class documentation

class App:

Known subclasses: cursers.ThreadedApp

Constructor: App(fps, keypad)

View In Hierarchy

The main application class that provides a context manager for curses apps.

The App class handles curses initialization and cleanup, provides an update loop with configurable FPS, and offers lifecycle hooks for application logic.

Method __enter__ Enter the application context and initialize curses.
Method __exit__ Exit the application context and cleanup curses.
Method __init__ Initialize the application.
Method is_exit_requested Check if an exit has been requested.
Method on_enter Handle entering the application context.
Method on_exit Handle exiting the application context.
Method on_update Handle frame updates.
Method request_exit Request the application to exit.
Method update Update the application state and handle input.
Instance Variable __is_exit_requested Undocumented
Instance Variable _fps Undocumented
Instance Variable _is_exit_requested Undocumented
Instance Variable _keypad Undocumented
Instance Variable _screen Undocumented
def __enter__(self) -> Self:
overridden in cursers.ThreadedApp

Enter the application context and initialize curses.

Returns
SelfThe application instance.
def __exit__(self, *args: object):
overridden in cursers.ThreadedApp

Exit the application context and cleanup curses.

Parameters
*args:objectException information (unused).
def __init__(self, *, fps: int = 30, keypad: bool = False):
overridden in cursers.ThreadedApp

Initialize the application.

Parameters
fps:intTarget frames per second (default: 30).
keypad:boolWhether to enable arrow keys (default: False).
def is_exit_requested(self) -> bool:

Check if an exit has been requested.

Returns
boolTrue if exit has been requested, False otherwise.
def on_enter(self, screen: Screen):

Handle entering the application context.

Override this method in your subclass to perform initialization tasks when the application starts.

Parameters
screen:ScreenThe Screen instance for drawing and input handling.
def on_exit(self, screen: Screen):

Handle exiting the application context.

Override this method in your subclass to perform cleanup tasks when the application exits.

Parameters
screen:ScreenThe Screen instance for drawing and input handling.
def on_update(self, screen: Screen):

Handle frame updates.

Override this method in your subclass to handle keyboard input and update your application state.

Parameters
screen:ScreenThe Screen instance for drawing and input handling.
def request_exit(self):

Request the application to exit.

Sets the exit flag to True, which will cause the application to exit on the next update cycle.

def update(self):

Update the application state and handle input.

Call this method in your main loop to update the application state and handle keyboard input.

__is_exit_requested: bool =

Undocumented

_fps =

Undocumented

_is_exit_requested: bool =

Undocumented

_keypad =

Undocumented

_screen =

Undocumented