You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code creates two refreshable buttons, each of which refreshes itself and notifies the user about it. But independent of which button is clicked, it always refreshes button B.
self.ui is static. By overriding the __get__ method, we keep track of the instance that is supposed to be used for the refresh() call.
But if we set the click handler directly like on_click=self.ui.refresh, the __get__ method isn't called when clicking the button and the last instance is used.
If we wrap the click handler in a lambda function like on_click=lambda: self.ui.refresh(), the __get__ method is called as part of the lambda function and correct instance is set before executing the refresh function.
Description
This observation originates from a StackOverflow question: https://stackoverflow.com/questions/76763206/is-it-possible-to-use-widgets-in-nicegui-python
The following code creates two refreshable buttons, each of which refreshes itself and notifies the user about it. But independent of which button is clicked, it always refreshes button B.
The problem can be avoided by replacing
with
But what is the reason for this mixup, and how to fix it?
The text was updated successfully, but these errors were encountered: