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 に答える