frm_L= Frame(frm2)
def gj():
s=str(t3.get('1.0',END)).split('\n')
for i in s:
if i!='':
bilibili().C(i)
t3=Text(frm_L,width=10,height=20)
t3.pack(side=TOP)
b1=Button(frm_L,text="press",width=10,command=gj)
b1.pack(side=BOTTOM)
frm_L.pack(side=LEFT)
这里是一部分代码,,我想做的事情是在按钮运行gj()方法的过程中,
也就是按钮是这种状态的情况下,,名字从‘press’变成我for循环里面的i字符串,,也就是可以能够随着我for循环一次,名字相应变成当前循环的i变量,
那问题来了,请问能再次设置button文本的方法是哪一个?
# explore Tkinter button as simple toggle
import Tkinter as tk # for Python3 use import tkinter as tk
def toggle_text():
"""toggle button text between Hi and Goodbye"""
if button["text"] == "Hi":
# switch to Goodbye
button["text"] = "Goodbye"
else:
# reset to Hi
button["text"] = "Hi"
root = tk.Tk()
root.title("Click the Button")
button = tk.Button( text="Hi", width=12, command=toggle_text)
button.pack(padx=100, pady=10)
root.mainloop()