Skip to content

send parameters in button on_press #1987

Closed Answered by mhsmith
alirezaimi asked this question in Q&A
Discussion options

You must be logged in to vote

You can do it by defining the handler like this:

def sw_relay(self, button, *, my_param, **kwargs):
   ...

Then using it like this:

from functools import partial
self.button_relay1 = toga.Button(
    "Sw 1 OFF",
    on_press=partial(self.sw_relay, my_param=1),
    style=Pack(padding=5, width=150, flex=1)
)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alirezaimi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants