+ 2

Working in module Tkinter

I have a 3 buttons and 1 function. How to add string from field 'text' of button to argument of function? Example: from tkinter import * def my_f(text_button): my_label.set("{} button".format(text_button)) b1 = Button(root, text="First", command=my_f) b2 = Button(root, text="Second", command=my_f) b3 = Button(root, text="Third", command=my_f) ...

15th Apr 2020, 3:16 PM
ŠŠ»ŠµŠŗсŠ°Š½Š“р Š’Š°ŃŠøŠ»ŃŒŠµŠ²
ŠŠ»ŠµŠŗсŠ°Š½Š“р Š’Š°ŃŠøŠ»ŃŒŠµŠ² - avatar
1 Answer
+ 2
I find solution: b1 = Button(root, text="First", command=lambda i="First": my_f(i)) Thanks
16th Apr 2020, 1:36 PM
ŠŠ»ŠµŠŗсŠ°Š½Š“р Š’Š°ŃŠøŠ»ŃŒŠµŠ²
ŠŠ»ŠµŠŗсŠ°Š½Š“р Š’Š°ŃŠøŠ»ŃŒŠµŠ² - avatar