tkinter中button

作者&投稿:酉郝 (若有异议请与网页底部的电邮联系)

源爱19215851081问: python编程:在Tkinter创建一个Button按钮,执行函数名称为sayhi -
通渭县靖邦回答: import tkinter root=tkinter.Tk() button1=tkinter.Button(root,text='hello',command=sayhi) root.mainloop() 不见得对,至少有点分吧

源爱19215851081问: python Tkinter button按钮按顺序被点击 -
通渭县靖邦回答: 思路:设一个全局变量:例如click def button1_click: global click #to do click = 1 def button2_click: global click if click = 1: #to do click = 2 def button3_click: global click if click = 2: #to do click = 3#余此类推.

源爱19215851081问: python Tkinter 脚本中 button的command所需的方法如何获得当前button的text -
通渭县靖邦回答: #你好,一个简单且完整的示例,分别使用面向过程和面向对象的方法进行描述: #面向对象----------------- import Tkinter class MyFrame: def __init__(self): 初始化窗口 frame = Tkinter.Tk() self.btn = Tkinter.Button(frame, text = "Hello", command...

源爱19215851081问: tkinter中计录一个button的点击次数 -
通渭县靖邦回答: from tkinter import * root=Tk() class count():def __init__(self):self.times=0 def __call__(self):self.times+=1 def gettimes(self):return self.times aclick=count() t=StringVar() text=Entry(root,textvariable=t) text.pack() Button(root,command=aclick,text="...

源爱19215851081问: python tkinter的button问题 -
通渭县靖邦回答: 不知到你的tkinter版本是啥? import Tkinter #首字母大写def hello():print(i)top = Tkinter.Tk() for i in range(0, 4):Tkinter.Button(top, text=i, command=hello).grid(row=1, column=i) top.mainloop()我打印的是0,1,2,3.如果解决了您的问题请采纳! 如果未解决请继续追问

源爱19215851081问: python Tkinter 一个Button的text是1 - 10中的随机数,如何获取它的text? -
通渭县靖邦回答: 11button.config('text')[-1] 返回按钮button的当前text

源爱19215851081问: python tkinter编程中如何把一个函数附加到Button上?,比如写计算器中的等于号 -
通渭县靖邦回答: #!/usr/bin/env python # -*- coding: utf-8 -*- import Tkinter class Window:def __init__(self, root):self.root = rootself.setbtn = Tkinter.Button(root, text='Set Text', command=self.Settxt)# 创建一个按钮对象,command= 这个地方就是当按钮按下去...

源爱19215851081问: python button如何定义的 -
通渭县靖邦回答: 贴代码,贴错误提示.这样的描述并不知道你为什么出现错误.(我猜是用python3的原因.)


本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网