Manager
Manager
A class that manages the main application loop, handling updates, drawing, and window lifecycle.
Specific kwargs
| Argument |
Type |
Description |
window |
Window | None |
the window to manage(default is None). |
Methods
| Name |
Kwargs |
Description |
on_draw |
None |
hook for custom drawing, called every frame. |
on_update |
events: list | None |
hook for custom updating, called every frame. |
exit |
None |
stops the main loop. |
on_start |
None |
hook called once before the main loop starts. |
on_exit |
None |
hook called after the main loop ends. |
first_update |
None |
hook called once before the first frame. |
first_draw |
None |
hook called once before the first frame. |
run |
None |
starts the main application loop. |
Getters
| Name |
ReturnType |
Description |
window |
Window |
current managed window. |
running |
bool |
current state of the main loop. |
dirty_mode |
bool |
is dirty mode enabled(default is False). |
force_quit |
bool |
will it force quit on exit(default is True). |
background |
tuple |
current background color(default is (0, 0, 0)). |
fps |
int |
target frames per second(default is 60). |
Setters
| Name |
Kwargs |
Description |
window |
window: Window |
sets the window to manage. |
running |
value: bool |
sets the state of the main loop. |
dirty_mode |
value: bool |
enables or disables dirty mode. |
force_quit |
value: bool |
enables or disables force quit on exit. |
background |
color: tuple |
sets the background color. |
fps |
value: int |
sets target frames per second. |
Use case
from nevu_ui import *
import pygame
pygame.init()
window = Window((500, 500), title = "Manager example")
menu = Menu(window, (100%vw, 100%vh))
class App(Manager):
def on_draw(self):
menu.draw()
def on_update(self, events):
menu.update()
app = App(window)
app.run()
from nevu_ui import *
import pyray
window = Window((500, 500), title = "Manager example", backend = Backend.RayLib)
menu = Menu(window, (100%vw, 100%vh))
class App(Manager):
def on_draw(self):
menu.draw()
def on_update(self, events):
menu.update()
app = App(window)
app.run()
Created with GGen v1.1.0 for nevu_ui v0.7.5