togglebutton with user input value #2945
Answered
by
falkoschindler
v479038280
asked this question in
Q&A
-
QuestionI add an argument to the ToggleButton,but I got this error: from nicegui import ui
class ToggleButton(ui.button):
def __init__(self,a:int=0,*args, **kwargs,) -> None:
super().__init__(*args, **kwargs)
self._state = a
self.on('click', self.toggle)
def toggle(self) -> None:
"""Toggle the button state."""
self.update()
def update(self) -> None:
self.props(f'color={"green" if self._state else "red"}')
super().update()
ToggleButton('Toggle me',a=1)
ui.run() |
Beta Was this translation helpful? Give feedback.
Answered by
falkoschindler
Apr 24, 2024
Replies: 1 comment
-
Hi @v479038280, Because |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
v479038280
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @v479038280,
Because
a:int=0
is the first positional argument,'Toggle me'
will be interpreted asa
.And
a=1
is anothera
.