Skip to content

Commit

Permalink
Merge pull request #2 from JP-Carr/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
why-keith authored Oct 9, 2020
2 parents ea7fdac + 8b4b2d8 commit 8393b5e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ dmypy.json
# Pyre type checker
.pyre/
*.pkl
log.txt
46 changes: 40 additions & 6 deletions tracker_gui.py → DnD_Time_Manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import PySimpleGUI as sg
import console_test as ct
from os import startfile
from time import sleep


layout=[
[sg.Text("Time")],
Expand All @@ -10,21 +13,52 @@

[sg.Text("Wind Speed"), sg.InputText(ct.db["windspeed"], size=(6,1), readonly=True,key="WS_display"), sg.Text("Wind Direction"), sg.InputText(ct.db["wind_dir"], size=(3,1), readonly=True,key="WD_display")],

[sg.InputText("0", size=(5,1), key="hour_input", enable_events=True, tooltip="Hour Change"), sg.InputText("0", size=(5,1), key="day_input", tooltip="Day Change"), sg.Button("Submit")]
[sg.Text("Time Adjustment"), sg.InputText("0", size=(5,1), key="hour_input", tooltip="Hour Change"), sg.InputText("0", size=(5,1), key="day_input", tooltip="Day Change"), sg.Button("Submit")],

[sg.InputText(size=(40,1), key="log_input", tooltip="Log Input"), sg.Button("Log"), sg.Button("Open Log")]
]

updatable=["hour_display", "day_display", "tenday_display", "month_display", "year_display"]+["temp_display", "precip_display"]+["WS_display", "WD_display"]
update_values=["{}:00".format(ct.db["hour"]), ct.db["day"], ct.db["tenday"], "{}. {}".format(ct.db["month"][0],ct.db["month"][1]), ct.db["year"]]+[ct.db["temperature"], ct.db["precipitation"]]+[ct.db["windspeed"], ct.db["wind_dir"]]
#update_values=["{}:00".format(ct.db["hour"]), ct.db["day"], ct.db["tenday"], "{}. {}".format(ct.db["month"][0],ct.db["month"][1]), ct.db["year"]]+[ct.db["temperature"], ct.db["precipitation"]]+[ct.db["windspeed"], ct.db["wind_dir"]]

window=sg.Window("D&D Time Manager", layout, finalize=True, icon="dnd_logo.ico")


#sg.theme("DarkRed1")
#print(len(updatable), len(update_values))

while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
# elif event==window["hour_input"]:
# print("asdfaf")
elif event=="Log":

# window["log_input"].Update(disabled=True)
# window["log_input"].Update(background_color="green")
try:
log=open("log.txt", "a")
log.write("{} {}/{}/{} - {}\n".format(str(ct.db["hour"])+":00", ct.db["day"], ct.db["month"][0], ct.db["year"], window["log_input"].Get()))

log.close()
window["log_input"].Update("")

except:
print("UNABLE TO LOG")

#else:

# sleep(0.5)
# window["log_input"].Update("", background_color="white")

# window["log_input"].Update(disabled=False)

elif event == "Open Log":
try:
startfile("log.txt")
except:
print("UNABLE TO OPEN LOG FILE")
log=open("log.txt", "a")
log.close()
startfile("log.txt")

elif event == "Submit":
try:
Expand All @@ -46,5 +80,5 @@
window["day_input"].Update("0")
else:
print (event)

window.close()

0 comments on commit 8393b5e

Please sign in to comment.