1
我需要一些幫助,將代碼搜索到文件中,然後返回所有相關的名稱。在提示符中正確打印列表,但在Tkinter GUI中,包含名稱的標籤重複上一個值。從Tkinter內部的For循環中返回不同的標籤(python)
例子:搜索路易斯費爾南多 - >
在提示:
[email protected]:~$ python teka.py
L 31 LUIZ FERNANDO GONÇALVES
L16 9 LUIZ FERNANDO SOUZA CARVALHO
L18 3 LUIZ FERNANDO CAVALHEIRO
L18 4 LUIZ FERNANDO S. DA SILVA
L19 10 LUIZ FERNANDO BELUZZO DA SILVA
在GUI
:
的代碼:
from Tkinter import *
#search func
def busca():
db = open('HD-Secretaria/morto.csv','r') #database file for name searching
x = entrada.get().upper()
for lines in db:
if x in lines:
print lines
result.set(lines)
Label(app, textvariable = result).pack()
#create window
app = Tk()
app.title('Gerenciador de arquivo morto')
app.geometry('500x400+200+100')
Label(app, text = 'Gerenciador de arquivo morto').pack() #title label
Label(app, text = 'Nome do cidadao').pack() #text label
entrada = Entry(app)
entrada.pack() #textbox
Button(app, text = 'Buscar', command = busca).pack() #button
#result label
result = StringVar()
result.set('')
l = Label(app, textvariable = result).pack()
app.mainloop()
我需要GUI來重新發送數據,如提示中所示。
幫我傢伙由xD
感謝布賴恩你真的解決myproblem,非常感謝 – bruno