[Question] How to use arguments in on_click #3970
-
QuestionI'm trying to call on_click function with args like this So how can I call that func with args Function I want to call is in another fileCode sample# Button with on_click
proceedLyrcis = ft.FloatingActionButton(
icon=ft.icons.CHECK_CIRCLE_OUTLINE_OUTLINED,
text="Start sync",
enable_feedback=True,
on_click=gen_line_inputs
)
# The Function
def gen_line_inputs(page, lines_cnt):
sync_fields_column = ft.Column()
page.controls.append(sync_fields_column)
for i in range(lines_cnt):
sync_fields_column.controls.append(editLine)
page.update() Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
you can use lambda function. |
Beta Was this translation helpful? Give feedback.
you can use lambda function.
on_click=lambda event:gen_line_inputs(page, lines_cnt)
assuming page and lines_cnt will be kept static.in case of dynamic arguments , assign values to your arguments and set them as defaults.
on_click=lambda event,page=page,lines_cnt=lines_cnt:gen_line_inputs(page, lines_cnt)