0

我有一些客户,例如customer1。我已经将他们的数据存储在这样的字典中:

customer1 = {"Age": 20, "Gender": "Male",}

我想要一个 Tkinter 输入框和一个名为的文本变量searchterm

searchterm = StringVar()
entry = Entry(frame, textvariable=searchterm)

然后我希望能够使用输入的值找到字典,然后在文本小部件中显示数据。

我是python新手,所以请帮忙。

4

1 回答 1

0

假设您有一个名为 frame1 的框架

#Create Text to present result and Entry for input

text1 = Text(frame1,bg="white",width=60)
entry1 = Entry(frame1,bg="yellow")

#The handler necessary to process input

def handler1(event):
        text1.delete(1.0,END)
        data=entry1.get()
        #What ever you want to do with data#
        #get result...#
        text1.insert(result)

#A button to engage your function with input

b1=Button(self,text="Open",width=20)
b1.bind("<Button-1>",handler1)
于 2013-05-04T17:56:25.000 回答