Upload files to "/"
This commit is contained in:
47
python.py
Normal file
47
python.py
Normal file
@ -0,0 +1,47 @@
|
||||
import PySimpleGUI as GUI
|
||||
import csv
|
||||
GUI.set_options(font='Arial 15')
|
||||
|
||||
layout = [
|
||||
[GUI.Text("First Name"), GUI.Push(), GUI.InputText(key='-fname-')],
|
||||
[GUI.Text("Last Name"), GUI.Push(), GUI.InputText(key='-lname-')],
|
||||
[GUI.Text("Phone Number"), GUI.Push(), GUI.InputText(key='-phone-')],
|
||||
[GUI.Text("Priority Level"), GUI.Push(), GUI.InputText(key='-PrLvl-')],
|
||||
[GUI.Button("Save")],
|
||||
[GUI.Text("LegacySearch by Last Name"),GUI.Push(),GUI.InputText(key='-Search-'),GUI.Button('Search')],
|
||||
[GUI.Text(key='-SearchOutput-')]
|
||||
]
|
||||
window = GUI.Window("Contact Book", layout)
|
||||
#The While True loop is considered essential
|
||||
while True:
|
||||
event, values = window.read()
|
||||
if event == GUI.WIN_CLOSED:
|
||||
print("GoodBye!")
|
||||
break
|
||||
#If that's not the case
|
||||
UserFirstName = values['-fname-']
|
||||
UserLastName = values['-lname-']
|
||||
UserPhoneNumber = values['-phone-']
|
||||
Priority = values['-PrLvl-']
|
||||
info = [UserFirstName, UserLastName, UserPhoneNumber, Priority]
|
||||
#If the user wishes to save
|
||||
if event == "Save":
|
||||
with open("info.csv", 'a', newline="") as w:
|
||||
csv.writer(w).writerow(info)
|
||||
print(info)
|
||||
#Now that your friend's info is saved locally,
|
||||
#Clear the fields
|
||||
window['-fname-'].update('')
|
||||
window['-lname-'].update('')
|
||||
window['-phone-'].update('')
|
||||
window['-PrLvl-'].update('')
|
||||
|
||||
SearchKeyWord = values['-Search-']
|
||||
if event == 'Search':
|
||||
with open("info.csv", 'r') as r:
|
||||
FileReader = csv.reader(r)
|
||||
for i in FileReader:
|
||||
if i[1] == SearchKeyWord:
|
||||
NewInfo = f"First Name:{i[0]}\nLast Name:{i[1]}\nPhone Number:{i[2]}\nPriority Level / Importance:{i[3]}\n"
|
||||
#Reusing window[obj].update(value) to update the empty label -SearchOutput-
|
||||
window['-SearchOutput-'].update(NewInfo)
|
Reference in New Issue
Block a user