MCPcopy
hub / github.com/zauberzeug/nicegui / page

Function page

tests/test_query.py:7–15  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5def test_query_body(screen: Screen):
6 @ui.page('/')
7 def page():
8 ui.label('Hello')
9 ui.query('body').classes('bg-orange-100')
10 ui.button('Red background', on_click=lambda: ui.query('body').classes(replace='bg-red-100'))
11 ui.button('Blue background', on_click=lambda: ui.query('body').classes(replace='bg-blue-100'))
12 ui.button('Small padding', on_click=lambda: ui.query('body').style('padding: 1px'))
13 ui.button('Large padding', on_click=lambda: ui.query('body').style('padding: 10px'))
14 ui.button('Data X = 1', on_click=lambda: ui.query('body').props('data-x=1'))
15 ui.button('Data X = 2', on_click=lambda: ui.query('body').props('data-x=2'))
16
17 def get_bg_classes() -> list[str]:
18 return [c for c in (screen.find_by_tag('body').get_attribute('class') or '').split() if c.startswith('bg-')]

Callers

nothing calls this directly

Calls 3

classesMethod · 0.45
styleMethod · 0.45
propsMethod · 0.45

Tested by

no test coverage detected