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

This commit is contained in:
Josh Biltonen 2022-08-25 19:27:35 -07:00
parent 11d7cbfd2e
commit c4657259c9
2 changed files with 33 additions and 9 deletions

0
db.json Normal file
View File

42
main.py
View File

@ -1,27 +1,48 @@
"""This is the main function""" """This is the main function"""
from copy import deepcopy
import PySimpleGUI as sg import PySimpleGUI as sg
from tinydb import TinyDB, Query
# Define the window's contents # Define the window's contents
layout = [[sg.Table([["word","Yes"]],["Serial Number","Brand","Grade","Name"])], layout = [[sg.Menu([['File', ['Open', 'Save', 'Add Computer',]]])],
[sg.Table([["word","Yes"]],["Serial Number","Brand","Grade","Name"],key = "table")],
[sg.Text("Serial Number")], [sg.Text("Serial Number")],
[sg.Input(key='-INPUT-')], [sg.Input(key='Serial Number')],
[sg.Text("Brand")], [sg.Text("Brand")],
[sg.Input(key='-INPUT-')], [sg.Input(key='Brand')],
[sg.Text("Grade")], [sg.Text("Grade")],
[sg.Input(key='-INPUT-')], [sg.Input(key='Grade')],
[sg.Text("Name")], [sg.Text("Name")],
[sg.Input(key='-INPUT-')], [sg.Input(key='Name')],
[sg.Text(size=(40,1), key='-OUTPUT-')], [sg.Text(size=(40,1), key='OUTPUT')],
[sg.Button('Check In'), sg.Button('Check Out')]] [sg.Button('Check In'), sg.Button('Check Out')]]
add_computer_layout = [[sg.Text("Serial Number")],
[sg.Input(key='-Serial Number-')],
[sg.Text("Brand")],
[sg.Input(key='Brand')],
[sg.Text("Grade")],
[sg.Input(key='Grade')],
[sg.Text("Name")],
[sg.Input(key='Name')],
[sg.Button('Add Computer'),]]
def add_computer():
window = sg.Window('Add Computer', deepcopy(add_computer_layout))
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED or event == 'Add Computer':
break
# Finish up by removing from the screen
window.close()
return values
def main(): def main():
"""Core of ComputerKeeper - The Main Application.""" """Core of ComputerKeeper - The Main Application."""
print("hello, world!") db= TinyDB("./db.json")
# Create the window # Create the window
window = sg.Window('Window Title', layout) window = sg.Window('Window Title', layout)
@ -31,8 +52,11 @@ def main():
# See if user wants to quit or window was closed # See if user wants to quit or window was closed
if event == sg.WINDOW_CLOSED or event == 'Quit': if event == sg.WINDOW_CLOSED or event == 'Quit':
break break
# Output a message to the window if event == 'Add Computer':
window['-OUTPUT-'].update('Hello ' + values['-INPUT-'] + "! Thanks for trying PySimpleGUI") new_computer = add_computer()
existing_table = window["table"].get()
existing_table+= list(new_computer.values())
window["table"].update(existing_table)
# Finish up by removing from the screen # Finish up by removing from the screen
window.close() window.close()