【发布时间】:2020-11-13 03:24:09
【问题描述】:
如果在文本字段中输入 2,为什么 y 不输出两次? 感谢您的帮助
from tkinter import *
root = Tk()
root.geometry("500x450")
def copy():
y = txt.get(1.0, END)
print(y)
if y == "2":
print("Check")
txt = Text(root, width=60, height=20, font=("Arial", 12))
txt.place(x=0, y=0)
btn = Button(root, text="Copy", command=copy)
btn.place(x=250, y=400)
mainloop()
【问题讨论】:
-
为什么不用
Entry而不是Text?