-
First Check
Example Codewith ui.link().bind_visibility_from(app.storage.user, "auth.uri") as link:
binding.bind_to(app.storage.user, "auth.uri", link.props, "href")
ui.button(
"JOIN US",
icon = "fa-brands fa-x-twitter",
color = "blue-grey-7"
)DescriptionHey guys, not really clear how to use bind_visibility_from. In my case I want link to be visible ONLY if NiceGUI Version3.3.1 Python Version3.13 BrowserFirefox Operating SystemLinux Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @masterjg, The problem is that binding does not work if there is no "auth.uri" in I recommend binding visibility from link = ui.link('Link')
link.bind_visibility_from(link.props, 'href')
app.storage.user.on_change(lambda: link.props.update(href=app.storage.user.get('auth.uri', '')))
app.on_connect(lambda: link.props.update(href=app.storage.user.get('auth.uri', '')))
ui.button('Remove URI', on_click=lambda: app.storage.user.pop('auth.uri', None))
ui.button('Google', on_click=lambda: app.storage.user.update({'auth.uri': 'https://www.google.com'}))
ui.button('YouTube', on_click=lambda: app.storage.user.update({'auth.uri': 'https://www.youtube.com'}))Note that I added |
Beta Was this translation helpful? Give feedback.
in the end I've also hadto add backward as it looks like by default href is "#"