Nov-16-2021, 01:18 AM
(This post was last modified: Nov-16-2021, 10:54 PM by Yoriz.
Edit Reason: Added prefix
)
I want to pass 2 numbers to a function in tkinter.
The numbers are in a list. The default values are numbers = [10, 2]
When I tried using partial(calcGrowth, numbers[0], numbers[1]) I always got the default values, even after I entered new values.
So I tried this with lambda, seems to work.
Is it the best way to pass the parameters to a function in tkinter?
The numbers are in a list. The default values are numbers = [10, 2]
When I tried using partial(calcGrowth, numbers[0], numbers[1]) I always got the default values, even after I entered new values.
So I tried this with lambda, seems to work.
Is it the best way to pass the parameters to a function in tkinter?
btn5 = tk.Button(frame1, text='calculate exponent', command=lambda: calcGrowth(numbers[0], numbers[1])) btn5.grid(columnspan=2, column=0, row=3, sticky='w', pady=10)