python 获取点击按钮名称_python如何获取tkinter组件的名称?比如按下多个Button中的一个,返回这个被按下的Button的text?...

这篇博客介绍了如何在Python的tkinter GUI中获取用户点击Button时的text内容。通过创建Button并设置command回调函数,可以实现当按下特定Button时,返回该Button的文本。
摘要由CSDN通过智能技术生成

import tkinter as tk

window = tk.Tk()

window.title('计算器')

window.geometry('360x435')

window.attributes("-alpha", 0.95)

window.resizable(0, 0)#窗口大小固定,不能缩放

var = tk.StringVar()

frm_1 = tk.Frame(window, width=360, height=115, bg='CadetBlue').place(x=0, y=0, anchor=tk.NW)#数字显示区

frm_2 = tk.Frame(window, width=270, height=240, bg='DarkSeaGreen').place(x=0, y=115, anchor=tk.NW)#数字键盘

frm_3 = tk.Frame(window, width=90, height=320, bg='Beige').place(x=270, y=115, anchor=tk.NW)#加减乘除

frm_4 = tk.Frame(window, width=270, height=80, bg='CadetBlue').place(x=0, y=355, anchor=tk.NW)#不可循环输出的

var_result = tk.StringVar()

var_dian=tk.StringVar()

var_dian.set('.')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值