标签:界面 main inter open python基础 数据 button name pat
1.内容输出类
import tkinter import python基础.day15.搜索数据可视化.BigDataFind class InputViem(): def __init__(self): self.win =tkinter.Tk() self.win.geometry("400x400+30+0") self.entry=tkinter.Entry(self.win) # input self.entry.place(x=0,y=0) self.button=tkinter.Button(self.win,text="搜索",command=self.search) self.button.place(x=200, y=0) def show(self): self.win.mainloop() def search(self): bigfind=python基础.day15.搜索数据可视化.BigDataFind.BigDataFind(r"文件地址") bigfind.find(self.entry.get()) bigfind.show()
2.输出查找类
import codecs import python基础.day15.搜索数据可视化.ShowDataInList class BigDataFind(): def __init__(self,path): self.file = codecs.open(path,"rb","gbk","ignore") # 打开文件 self.showdata=python基础.day15.搜索数据可视化.ShowDataInList.ShowDataInList() def find(self,searchstr): while True: line = self.file.readline() print(line) if line.find(searchstr) != -1: print(line,end="") # 显示数据 self.showdata.adddata(line) # 插入数据 if not line: # 都不到数据 break def show(self): self.showdata.show() # 显示查找到的内容 def __del__(self): self.file.close() if __name__ == ‘__main__‘: bigfind = BigDataFind(r"测试地址") bigfind.find("陕西省渭南市") bigfind.show()
3.输出内容显示界面类
import tkinter class ShowDataInList(): def __init__(self): self.win=tkinter.Tk() self.win.geometry("1000x900+0+0") self.list=tkinter.Listbox(self.win,width="1000",height="800") # list self.list.pack() # 加载到窗体 def show(self): self.list.mainloop() def adddata(self,insert): self.list.insert(tkinter.END,insert) # 插入数据
4.主函数调用类
import python基础.day15.搜索数据可视化.InputViem inputviem = python基础.day15.搜索数据可视化.InputViem.InputViem() inputviem.show()
标签:界面 main inter open python基础 数据 button name pat
原文地址:https://www.cnblogs.com/wang102030/p/9472634.html