我想从输入中获取一个值,但是那没用

问题描述 投票:0回答:1

问题是:

return self.func(*args)
TypeError: b1_pg() missing 1 required positional argument: 'e1'

我搜索了整个Google,但没有发现任何东西

from tkinter import *
from tkinter import ttk
from functools import partial

root = Tk()
root.geometry('400x200+100+200')
def b1_pg(e1):
    search = str(e1.get())
    print(search)
    return search

what = ttk.Label(root, text="who do you want to search about???").grid(row=1, column=0)

e1 = ttk.Entry(root, width=40).grid(row=1, column=1)

b1 = ttk.Button(root, text="if you are ready prees here", command=b1_pg).grid(row=2, column=0)

#information=ttk.Label(root,text=family{search})

root.title('family')
root.mainloop()

我期望代码在我按下按钮时从e1(entry)中获取值,但它给我一个错误

return self.func(*args)
TypeError: b1_pg() missing 1 required positional argument: 'e1'

我的代码出什么问题了?

python-3.x tkinter functools
1个回答
0
投票

您需要在此处纠正一些问题。

© www.soinside.com 2019 - 2024. All rights reserved.