diff --git a/db.json b/db.json index 8a7cfba..1fa0494 100644 --- a/db.json +++ b/db.json @@ -1 +1 @@ -{"_default": {"1": {"Serial Number": "123", "Brand": "d", "Grade": "7", "Name": "jb"}}} \ No newline at end of file +{"_default": {"1": {"Serial Number": "123", "Brand": "d", "Grade": "7", "Name": "jb"}, "2": {"Serial Number": "1", "Brand": "2", "Grade": "3", "Name": "4"}}} \ No newline at end of file diff --git a/main.py b/main.py index 72cbc91..9ee5a4f 100644 --- a/main.py +++ b/main.py @@ -6,8 +6,9 @@ from tinydb import TinyDB, Query # Define the window's contents -layout = [[sg.Menu([['File', ['Open', 'Save', 'Add Computer',]]])], - [sg.Table([["word","Yes"]],["Serial Number","Brand","Grade","Name"],key = "table")], +colum_lut = ["Serial Number","Brand","Grade","Name"], +layout = [[sg.Menu([['File', ['Open', 'Save', 'Add Computer',]]])] + [sg.Table([["word","Yes"]],colum_lut,key = "table")], [sg.Text("Serial Number")], [sg.Input(key='Serial Number')], [sg.Text("Brand")], @@ -43,8 +44,16 @@ def add_computer(): def main(): """Core of ComputerKeeper - The Main Application.""" db= TinyDB("./db.json") + Computer = [] + for item in db.all(): + print(item) + The_Device = [] + for colum in colum_lut: + The_Device.append(item[colum]) + Computer.append(The_Device) # Create the window - window = sg.Window('Window Title', layout) + window = sg.Window('Window Title', layout, finalize=True) + window["table"].update(Computer) # Display and interact with the Window using an Event Loop while True: