TickyWill / BiblioMeter

Toolbox for bibliometric purpose
MIT License
0 stars 0 forks source link

How to pass arguments to a Button command in Tkinter? #4

Open BaptisteRefalo opened 4 months ago

BaptisteRefalo commented 4 months ago

It is not an issue (not reported by pylint when arguments are involved) but rather an alternative to the use of "empty lambda" in that case:

from functools import partial
#(...)
action_with_arg = partial(action, arg)
button = Tk.Button(master=frame, text='press', command=action_with_arg)

If several arguments are used, then it is something like: partial(action, arg1, arg2, ..., argN)

BaptisteRefalo commented 4 months ago

Source: https://stackoverflow.com/questions/6920302/how-to-pass-arguments-to-a-button-command-in-tkinter