From 2db9b7160564b26299b98e25b3f87a3a826b7092 Mon Sep 17 00:00:00 2001 From: Josh b Date: Fri, 21 Oct 2022 17:49:05 -0700 Subject: [PATCH] Finished Search --- main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 9b0a891..c1dccf4 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ WINDOW=None # Define the window's contents colum_lut = ["Serial Number","Brand","Grade","Name"] layout = [[sg.Menu([['File', ['Open', 'Save', 'Add Computer','Remove Computer']]])], - [sg.Text("search"), sg.Input(s=(35,))], + [sg.Text("search"), sg.Input(s=(35,), enable_events=True,key="search")], [sg.Input(s=(19,),enable_events=True,key="filter Serial Number"), sg.Input(s=(6,),enable_events=True,key="filter Brand"), sg.Input(s=(6,),enable_events=True,key="filter Grade"), @@ -110,6 +110,16 @@ def main(): result=db.search(Computers[event[7:]].test(filter_database)) window["table"].update(format_table(result)) + elif event == "search": + filter_database = lambda s: s.lower().find(values[event].lower()) != -1 + Computers=Query() + result=db.search( + Computers["Serial Number"].test(filter_database)| + Computers["Brand"].test(filter_database)| + Computers["Grade"].test(filter_database)| + Computers["Name"].test(filter_database) + ) + window["table"].update(format_table(result)) # Finish up by removing from the screen window.close()