Skip to content

Button

Button

A standard clickable button.

Button is a subclass of: Label

Specific kwargs

Argument Type Description
function Callable callback function.
is_active bool can be clicked(default is True).
throw_errors bool throw errors on custom click(default is False).

Use case

from nevu_ui import *
import pygame

pygame.init()

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

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

layout = Grid([100%fillw, 100%fillh], x=3, y=3)

widget = Button(lambda: print("Hi!"), "Text", (100, 100))

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

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

layout = Grid([100%fillw, 100%fillh], x=3, y=3)

widget = Button(lambda: print("Hi!"), "Text", (100, 100))

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