Skip to content

State var

StateVariable

A generic container that holds different values for different UI states (static, hover, active). Warning: may encounter issues

Specific kwargs

Argument Type Description
static Any value for the normal, un-hovered state.
hover Any value for the hovered state.
active Any value for the active/clicked state.

Methods

Name Kwargs Description
__getitem__ name: str | int returns the value for the specified state (0/'static', 1/'hover', 2/'active').
__setitem__ name: int | str, value: Any sets the value for the specified state.

Getters

Name ReturnType Description
static Any current static state value.
hover Any current hover state value.
active Any current active state value.

Setters

Name Kwargs Description
static value: Any sets static state value.
hover value: Any sets hover state value.
active value: Any sets active state value.

Use case

from nevu_ui import *
import pygame

pygame.init()

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

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

layout = Grid([100%fillw, 100%fillh], x=3, y=3)
style = Style(border_radius = 15, border_width = StateVariable(0, 1, 3))
widget = Widget(size = (100, 100), style = style, hoverable = True, clickable = True)
layout.add_item(widget, 2, 2)

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 = "StateVariable example", backend = Backend.RayLib)

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

layout = Grid([100%fillw, 100%fillh], x=3, y=3)
style = Style(border_radius = 15, border_width = StateVariable(0, 1, 3))
widget = Widget(size = (100, 100), style = style, hoverable = True, clickable = True)
layout.add_item(widget, 2, 2)

menu.layout = layout

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

Created with GGen v1.1.0 for nevu_ui v0.7.5