From 0750fda030894c671c93d4b31855a19184ceec3c Mon Sep 17 00:00:00 2001 From: Brightbites <45047787+Brightbites@users.noreply.github.com> Date: Wed, 25 Feb 2026 04:45:05 +0000 Subject: [PATCH] added potential method for timer --- GUI.py | 70 ++++++++++++++++++++++++++++++++++-------------------- backend.py | 24 ++++--------------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/GUI.py b/GUI.py index a10f957..598209f 100644 --- a/GUI.py +++ b/GUI.py @@ -1,7 +1,8 @@ import dearpygui.dearpygui as dpg import backend +import time -def GUI(): +if __name__ == '__main__': dpg.create_context() dpg.create_viewport(title='RocketLaunchCountdown', min_width=600, min_height=400, width=600, height=400) @@ -10,9 +11,8 @@ def GUI(): default_font = dpg.add_font("OpenSans-Medium.ttf", 128) second_font = dpg.add_font("OpenSans-Medium.ttf", 36) - with dpg.window(tag="Primary Window"): - BIG = dpg.add_button(label="T- 00:00:00", tag="text item") + timer = dpg.add_button(label="T- 00:00:00", tag="text item") dpg.add_separator() with dpg.group(horizontal=True): dpg.add_button(label="Start", tag="Start") @@ -23,7 +23,7 @@ def GUI(): dpg.add_input_int(min_value=0, max_value=23, min_clamped=True, max_clamped=True, step=0, tag="Hours") dpg.add_input_int(min_value=0, max_value=59, min_clamped=True, max_clamped=True, step=0, tag="Minutes") dpg.add_input_int(min_value=0, max_value=59, min_clamped=True, max_clamped=True, step=0, tag="Seconds") - dpg.add_button(label="Toggle Date Till", tag="toggleDate", callback="toggleDateView") + dpg.add_button(label="Toggle Date Till", tag="toggleDate", callback="toggledateview") with dpg.group(horizontal=True): dpg.add_input_int(min_value=1, max_value=31, min_clamped=True, max_clamped=True, step=0, tag="Day") dpg.add_input_int(min_value=1, max_value=12, min_clamped=True, max_clamped=True, step=0, tag="Month") @@ -48,39 +48,57 @@ def GUI(): dpg.add_text("Year") dpg.bind_font(second_font) - dpg.bind_item_font(BIG, default_font) + dpg.bind_item_font(timer, default_font) - dpg.show_style_editor() + dpg.show_metrics() dpg.setup_dearpygui() dpg.show_viewport() dpg.set_primary_window("Primary Window", True) currentViewportSize = 0 + seccondPassed = 0 - while dpg.is_dearpygui_running(): - if not dpg.get_viewport_client_width() == currentViewportSize: - dpg.configure_item("text item", width=int(dpg.get_viewport_width() - 16)) - dpg.configure_item("Start", width=int((dpg.get_viewport_client_width() / 4) - 10)) - dpg.configure_item("Hold", width=int((dpg.get_viewport_client_width() / 4) - 10)) - dpg.configure_item("Scrub", width=int((dpg.get_viewport_client_width() / 4) - 10)) - dpg.configure_item("toggle", width=int((dpg.get_viewport_client_width() / 4) - 10)) - dpg.configure_item("Day", width=int((dpg.get_viewport_client_width() / 3) - 11)) - dpg.configure_item("Month", width=int((dpg.get_viewport_client_width() / 3) - 11)) - dpg.configure_item("Year", width=int((dpg.get_viewport_client_width() / 3) - 11)) - dpg.configure_item("Hours", width=int((dpg.get_viewport_client_width() / 4) - 10)) - dpg.configure_item("Minutes", width=int((dpg.get_viewport_client_width() / 4) - 10)) - dpg.configure_item("Seconds", width=int((dpg.get_viewport_client_width() / 4) - 10)) - dpg.configure_item("toggleDate",width=int((dpg.get_viewport_client_width() / 4) - 10)) + while dpg.is_dearpygui_running(): # on every frame + if not dpg.get_viewport_client_width() == currentViewportSize: # has it been resized currentViewportSize = dpg.get_viewport_client_width() - #if seccondPassed: - # backend.countdownTime() - # seccondPassed = False - # timeFinished = 0 + dpg.configure_item("text item", width=int(currentViewportSize - 16)) + dpg.configure_item("Start", width=int((currentViewportSize / 4) - 10)) + dpg.configure_item("Hold", width=int((currentViewportSize / 4) - 10)) + dpg.configure_item("Scrub", width=int((currentViewportSize / 4) - 10)) + dpg.configure_item("toggle", width=int((currentViewportSize / 4) - 10)) + dpg.configure_item("Day", width=int((currentViewportSize / 3) - 11)) + dpg.configure_item("Month", width=int((currentViewportSize / 3) - 11)) + dpg.configure_item("Year", width=int((currentViewportSize / 3) - 11)) + dpg.configure_item("Hours", width=int((currentViewportSize / 4) - 10)) + dpg.configure_item("Minutes", width=int((currentViewportSize / 4) - 10)) + dpg.configure_item("Seconds", width=int((currentViewportSize / 4) - 10)) + dpg.configure_item("toggleDate",width=int((currentViewportSize / 4) - 10)) + + #if seccondPassed == abs(time.monotonic()): # has a seccond passed since last run + # seccondPassed = abs(time.monotonic() + 1) + # if not onHold: + # countTime = backend.countTime(countTime) + # displayTime = abs(countTime) + # holdTime = 0 + # else: + # holdTime = backend.holdTime(holdTime) + # displayTime = abs(countTime) + + #update button to display time dpg.render_dearpygui_frame() dpg.destroy_context() -if __name__ == '__main__': - GUI() \ No newline at end of file +def toggledateview(sender, app_data): + if dateInputVisable: + dateInputVisable = False + dpg.configure_item("Day", enabled=False) + dpg.configure_item("Month", enabled=False) + dpg.configure_item("Year", enabled=False) + else: + dateInputVisable = True + dpg.configure_item("Day", enabled=True) + dpg.configure_item("Month", enabled=True) + dpg.configure_item("Year", enabled=True) diff --git a/backend.py b/backend.py index 27d54fd..ec258a9 100644 --- a/backend.py +++ b/backend.py @@ -62,25 +62,11 @@ def pullSpreedsheet(inputCol, inputRow, link): print(f"[ERROR] Failed to fetch Go/No-Go from sheet: {e}") return "N/A" -def countdownTime(countTime, onHold): - TimeNow = countTime - while True: - while not onHold: - t1 = monotonic() - TimeNow = TimeNow - 1 - if TimeNow <= 0: # are we counting up? - countUp = True - else: countUp = False - yield(abs(TimeNow), countUp) - t2 = monotonic() - sleep(1.0 - (t2 - t1)) # sleep till next seccond - HoldTime = 0 - while onHold: - t1 = monotonic() - HoldTime = HoldTime + 1 - yield(HoldTime, True) - t2 = monotonic() - sleep(1.0 - (t2 - t1)) # sleep till next seccond +def countTime(timeNow): + pass + +def holdTime(timeNow): + pass def convertEpoch(inputTime, isDate):