Declarative
Building first app with declarative way
First thing first, import nevu-ui and create a Manager subclass.
import nevu_ui as ui
import pygame
pygame.init()
class MyApp(ui.Manager):
MyApp you need to override __init__ and create Window inside it:
To create a Window you must specify size other arguments are not required, Window initializes screen with specified backend(default is pygame):
def __init__(self):
window = ui.Window((800, 600), title="Nevu UI App")
Menu, you'll need to put window and size as it's arguments:
...
menu = ui.Menu(window, ui.fill_all, layout = ...)
Grid:
#inside menu creation
layout = ui.Grid(ui.fill_all, row=3, column=3,
content = {
(2, 2): ui.Label("Nevu UI", (50%ui.vw, 33%ui.vh))
})
Window and Menu are created lets pass them to the parent manager's __init__ method:
super().__init__(window, menu)
app = MyApp()
app.run()
Full code
import nevu_ui as ui
import pygame
pygame.init()
class MyApp(ui.Manager):
def __init__(self):
window = ui.Window((800, 600), title="Nevu UI App")
menu = ui.Menu(window, ui.fill_all,
layout = ui.Grid(ui.fill_all, row=3, column=3,
content = {
(2, 2): ui.Label("Nevu UI", (50%ui.vw, 33%ui.vh))
}))
super().__init__(window, menu)
app = MyApp()
app.run()