Skip to content

Commit

Permalink
Added "open log" button
Browse files Browse the repository at this point in the history
  • Loading branch information
JP-Carr committed Sep 10, 2020
1 parent 8f43647 commit a6b6b70
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions 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 @@ -12,11 +15,11 @@

[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.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")

Expand All @@ -28,12 +31,33 @@
if event == sg.WIN_CLOSED:
break
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()

log.close()

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 @@ -56,4 +80,4 @@
else:
print (event)

window.close()
window.close()

0 comments on commit a6b6b70

Please sign in to comment.