How does python get the name of a tkinter component? For example, press one of multiple Button to return the text? of the pressed Button

import tkinter as tk

window = tk.Tk()
window.title("")
window.geometry("360x435")
window.attributes("-alpha", 0.95)
window.resizable(0, 0)-sharp

var = tk.StringVar()


frm_1 = tk.Frame(window, width=360, height=115, bg="CadetBlue").place(x=0, y=0, anchor=tk.NW)-sharp
frm_2 = tk.Frame(window, width=270, height=240, bg="DarkSeaGreen").place(x=0, y=115, anchor=tk.NW)-sharp
frm_3 = tk.Frame(window, width=90, height=320, bg="Beige").place(x=270, y=115, anchor=tk.NW)-sharp
frm_4 = tk.Frame(window, width=270, height=80, bg="CadetBlue").place(x=0, y=355, anchor=tk.NW)-sharp

var_result = tk.StringVar()
var_dian=tk.StringVar()
var_dian.set(".")


def name(u):
    u="var"+str(u)
    return u

-sharp
I = tk.Entry(frm_1,textvariable=var_result,font=("Arial",40),bg="grey")
I.place(x=0,y=0,width=360,height=115)
-sharp

-sharp

-sharp
def show_result():
    result = I.get()
    print(eval(result))

def delete():
    f.delete(1.0, tk.END)

def get():
    pass


num=1
-sharp
for j in range(3):
    for i in range(3):

        m=0+(i)*90
        n=115+(j)*80
        b=tk.Button(frm_2,text=num,bg="WhiteSmoke",font=("Arial","20"),command=get)
        b.place(x=m,y=n,width=90,height=80)
        num=num+1
-sharp
v=0

a=tk.Button(frm_4,textvariable=var_dian,bg="Gainsboro",font=("20")).place(x=0,y=355,width=90,height=80)
b=tk.Button(frm_4,text="=",bg="Gainsboro",font=("20"),command=show_result).place(x=180,y=355,width=90,height=80)
f=tk.Button(frm_4,text="0",bg="WhiteSmoke",font=("Arial","20")).place(x=90,y=355,width=90,height=80)



-sharp
q=0
for p in ["+","-","*","/"]:
    e=tk.Button(frm_3,text=p,bg="Gainsboro",font=("20")).place(x=270,y=115+q*80,width=90,height=80)
    q=q+1

window.mainloop()
Dec.22,2021

take a look at this document: http://effbot.org/tkinterbook.

study the event correlation. Then you will find events such as [left mouse button click] [left mouse button double click] and so on.

def get(*args):
    return args


b=tk.Button(frm_2,text=num,bg='WhiteSmoke',font=('Arial','20'))
b.bind('<Button-1>', func=get)

over the mountains and mountains to find a solution, just put button in the array

array=[tk.Button(frm_4,text='=',bg='Gainsboro',font=('20'),command=get_result)]
for i in array:
    print(type(i))
    i.place(x=180,y=355,width=90,height=80)
    print(i.cget("text"))
    print(i["text"])
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39cfe-2c1b8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39cfe-2c1b8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?