Using Javascript

You can easily do DOM manipulation or add custom events to NUI components

Accessing DOM

The DOM node for NUI components can be accessed via self.dom

self.label_1.dom.setAttribute("key", "value")

Adding JS Events

NUI components already support a wider range of events that are well-suited for all basic needs. However, to add more events, you can use the add_event method.

self.label_1.add_event("click", self.label_1_click)

def label_1_click(self, **event_args):
    print(event_args['sender']) #The sender of the event
    print(event_args['event']) #JS event info

Last updated