Skip to content

Can we add classes to the body of the current page? #310

Closed Answered by rodja
smojef asked this question in Q&A
Discussion options

You must be logged in to vote

@smojef your example code does not use page creators. Therefore NiceGUI can not provide you with a client object. If you want to stick with the globally shared index page, you can access its client via globals.index_client. Also most of the time you do not need to work with the QLayout but rather use the content property of the client. Thats why you need to navigate through the tree to via default_slots from layout to content. A working example would be:

from nicegui import ui, globals

def on_add():
    with globals.index_client.content:
        ui.label('add a label to the bottom of main page')

ui.button('Add', on_click=on_add)

ui.run()

While this works, I generally suggest to move to…

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@falkoschindler
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by smojef
Comment options

You must be logged in to vote
2 replies
@rodja
Comment options

rodja Feb 3, 2023
Maintainer

@smojef
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants