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