【发布时间】:2019-04-14 23:24:11
【问题描述】:
这是我的第一个 python 应用程序,如果答案很明显,请不要笑。
我需要从 2 个条目中获取 2 个值,然后按下一个按钮将它们存储到变量中。我使用 tkinter 来设计我的 GUI。我可以让按钮将在“entry1”中输入的值存储在变量 entry1 中,但不能让按钮同时存储第二个。
TLDR: 按下按钮时 来自 entry1 的文本被存储到 entry1 变量中 来自 entry2 的文本被存储到 entry2 变量中
您将在下面找到我仅用于 1 个操作的代码(从 entry1 变量中的 entry1 获取文本)
def get_code_cl(entry1):
print(entry1)
def get_Dade_cl(entry):
print(entry2)
button = tk.Button(frame, text="Search",bg='red',font=20,fg='white', command=lambda: get_code_cl(entry.get()))
button.place(relx=0.21, rely=0.01, relheight=0.23, relwidth=0.11)
【问题讨论】:
标签: python-3.x button tkinter