diff --git a/console_test.py b/console_test.py index 82361af..c79b0b2 100644 --- a/console_test.py +++ b/console_test.py @@ -67,8 +67,12 @@ def hour(x): db["hour"]+=int(x) while db["hour"]>=24: db["hour"]-=24 - db["day"]+=1 + db["day_raw"]+=1 next_day() + while db["hour"]<0: + db["hour"]+=24 + db["day_raw"]-=1 + next_day(-1) print("Time: {}:00".format(db["hour"])) except TypeError as e: print("INVALID TIME INCREMENT") diff --git a/dnd_logo.ico b/dnd_logo.ico new file mode 100644 index 0000000..75406b8 Binary files /dev/null and b/dnd_logo.ico differ diff --git a/tracker_gui.py b/tracker_gui.py index 523e3d3..0caefb9 100644 --- a/tracker_gui.py +++ b/tracker_gui.py @@ -1,76 +1,31 @@ import PySimpleGUI as sg import console_test as ct -""" -sg.theme('DarkAmber') # Add a touch of color -# All the stuff inside your window. -layout = [ [sg.Text('Some text on Row 1')], - [sg.Text('Enter something on Row 2'), sg.InputText("inout",readonly=True)], - [sg.Button('Ok'), sg.Button('Cancel'), sg.Button("Save")] ] - -# Create the Window -window = sg.Window('Window Title', layout) -# Event Loop to process "events" and get the "values" of the inputs -while True: - event, values = window.read() - if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel - break - if event=="Save": - print("saved") - if event=="Ok": - print('You entered ', values[0]) - layout[1][1].update(value="ewatwe") - - - print(event) -window.close() -""" -""" -x=0 -layout=[ - [sg.Text("Time"), sg.InputText(str(x), readonly=True,key="number")], - [sg.Button("+1",key="+1"), sg.Button("-1",key="-1")] - ] - -window=sg.Window("Test",layout) -while True: - event, values = window.read() - if event == sg.WIN_CLOSED: - print("asdf") - break - elif event=="+1": - x+=1 - window["number"].Update(str(x)) - #layout[0][1].Update(str(x)) - elif event=="-1": - x-=1 - layout[0][1].Update(str(x)) - -window.close() - -""" - layout=[ [sg.Text("Time")], - [sg.InputText("{}:00".format(ct.db["hour"]),size=(10,1), readonly=True,key="hour_display"), sg.InputText(ct.db["day"], size=(7,1), readonly=True,key="day_display"), sg.InputText(ct.db["tenday"], size=(10,1), readonly=True,key="tenday_display"), sg.InputText("{}. {}".format(ct.db["month"][0],ct.db["month"][1]), size=(30,1), readonly=True,key="month_display"), sg.InputText(ct.db["year"], size=(5,1), readonly=True,key="year_display")], + [sg.InputText("{}:00".format(ct.db["hour"]),size=(6,1), readonly=True,key="hour_display", tooltip="Time - 24 hour"), sg.InputText(ct.db["day"], size=(3,1), readonly=True,key="day_display", tooltip="Day of the month"), sg.InputText(ct.db["tenday"], size=(2,1), readonly=True,key="tenday_display", tooltip="Tenday"), sg.InputText("{}. {}".format(ct.db["month"][0],ct.db["month"][1]), size=(30,1), readonly=True,key="month_display", tooltip="Month"), sg.InputText(ct.db["year"], size=(5,1), readonly=True,key="year_display", tooltip="Year - DR")], [sg.Text("Temperature"), sg.InputText(ct.db["temperature"], size=(20,1), readonly=True,key="temp_display"), sg.Text("Precipitation"), sg.InputText(ct.db["precipitation"], size=(6,1), readonly=True,key="precip_display")], [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"), sg.InputText("0", size=(5,1), key="day_input"), sg.Button("Submit")] + [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")] ] -#updatable=[i for i in layout[1]]+[layout[2][1], layout[2][3]]+[layout[3][1], layout[3][3]] 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"]] -window=sg.Window("D&D Time Manager",layout, finalize=True) + +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 == "Submit": try: h=int(window["hour_input"].Get()) @@ -88,9 +43,8 @@ for i in range(len(updatable)): window[updatable[i]].Update(update_values[i]) window["hour_input"].Update("0") - window["day_input"].Update("0") - - - + window["day_input"].Update("0") + else: + print (event) window.close() \ No newline at end of file