Filter system
All checks were successful
Potlatch Loggers Organization/ComputerKeeper/pipeline/head This commit looks good

This commit is contained in:
Josh Biltonen 2022-10-21 17:20:57 -07:00
parent dc018d5d83
commit 1940c954e9

22
main.py
View File

@ -57,20 +57,24 @@ def add_computer():
window.close()
return values
def main():
"""Core of ComputerKeeper - The Main Application."""
global TABLE,WINDOW
db= TinyDB("./db.json")
def format_table(table_list):
Computer = []
for item in db.all():
for item in table_list:
The_Device = []
for colum in colum_lut:
The_Device.append(item[colum])
Computer.append(The_Device)
return Computer
def main():
"""Core of ComputerKeeper - The Main Application."""
global TABLE,WINDOW
db= TinyDB("./db.json")
computer = format_table(db.all())
# Create the window
window = sg.Window('Window Title', layout, finalize=True)
WINDOW=window
window["table"].update(Computer)
window["table"].update(computer)
table = window['table'].Widget
table.bind('<Double-1>', double_click, add='+')
TABLE=table
@ -100,11 +104,11 @@ def main():
print(f'Click on column {column}')
# Sort data on the table by the value of column
# then update window['-TABLE-'].update(values=new_data)
else:
print(event, values[event])
elif event.find("filter") != -1:
filter_database = lambda s: s.lower().find(values[event].lower()) != -1
Computers=Query()
print(db.search(Computers[event[7:]].test(filter_database)))
result=db.search(Computers[event[7:]].test(filter_database))
window["table"].update(format_table(result))
# Finish up by removing from the screen