Skip to content

Base layout

LayoutType

A basic layout without any logic for arranging elements.

Specific kwargs

Argument Type Description
content [NevuObject] initial content.
borders BorderConfig specific border configuration.

Methods

Name Kwargs Description
add_item item: NevuObject adds item to the layout.
add_floating_item item: NevuObject adds floating item to the layout.
get_item_by_id id: str searching by id returns item or None.
get_item_by_id_strict id: str searching by id returns item or raises exception.
add_items Specific for layout only works in children.
apply_style_to_childs style: Style applies a new style to all child components recursively.
apply_style_patch_to_childs **patch: Unpack[StyleKwargs] applies style updates to all child components recursively.
read_item_coords item: NevuObject re-reads and updates dimensions for the specified item.
get_item_list_pos item: NevuObject returns the index of the item inside layout list.
is_item_floating item: NevuObject returns True if the item is floating.
kill_item_by_id id: str destroys and removes the item with the specified ID.
kill_item item: NevuObject destroys and removes the specified item from the layout.

Static methods

Name Kwargs ReturnType Description
is_layout item: Any bool returns True if item is a LayoutType.
is_widget item: Any bool returns True if item is a Widget.

LayoutType is a subclass of: NevuObject

Use case

from nevu_ui import *
import pygame

pygame.init()

window = Window((500, 500), title = "LayoutType example")

menu = Menu(window, (100%vw, 100%vh))

lbla = Label("A", [100, 50], single_instance = True) #Single instance is important
lblb = Label("B", [100, 50], single_instance = True)

lbla.coordinates = NvVector2(50, 50) #nvvector 2 in IMPORTANT !!!
lblb.coordinates = NvVector2(200, 200)

layout = LayoutType([100*vw, 100*vh])
layout.add_floating_item(lbla)
layout.add_floating_item(lblb)

menu.layout = layout
while True:
    window.begin_frame()
    window.update()
    menu.update()
    menu.draw()
    window.end_frame()
from nevu_ui import *
import pyray

window = Window((500, 500), title = "LayoutType example", backend = Backend.RayLib)

menu = Menu(window, (100%vw, 100%vh))

lbla = Label("A", [100, 50], single_instance = True) #Single instance is important
lblb = Label("B", [100, 50], single_instance = True)

lbla.coordinates = NvVector2(50, 50) #nvvector 2 in IMPORTANT !!!
lblb.coordinates = NvVector2(200, 200)

layout = LayoutType([100*vw, 100*vh])
layout.add_floating_item(lbla)
layout.add_floating_item(lblb)

menu.layout = layout
while True:
    window.begin_frame()
    window.update()
    menu.update()
    menu.draw()
    window.end_frame()

Created with GGen v1.3.0 for nevu_ui v0.8.2