watch as i make this input disapear

This commit is contained in:
Brightbites
2026-02-26 09:26:59 +00:00
parent 0750fda030
commit 45d4786e26
2 changed files with 105 additions and 96 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
__pycache__

66
GUI.py
View File

@@ -2,16 +2,34 @@ import dearpygui.dearpygui as dpg
import backend import backend
import time import time
if __name__ == '__main__': def toggleDate():
dpg.create_context() global dateInputVisable
dpg.create_viewport(title='RocketLaunchCountdown', min_width=600, min_height=400, width=600, height=400) if dateInputVisable:
dateInputVisable = False
dpg.configure_item("Day", show=False, enabled=False)
dpg.configure_item("Month", show=False, enabled=False)
dpg.configure_item("Year", show=False, enabled=False)
dpg.configure_item("dayTooltip", show=False)
dpg.configure_item("monthTooltip", show=False)
dpg.configure_item("yearTooltip", show=False)
else:
dateInputVisable = True
dpg.configure_item("Day", show=True, enabled=True)
dpg.configure_item("Month", show=True, enabled=True)
dpg.configure_item("Year", show=True, enabled=True)
dpg.configure_item("dayTooltip", show=True)
dpg.configure_item("monthTooltip", show=True)
dpg.configure_item("yearTooltip", show=True)
with dpg.font_registry(): dpg.create_context()
dpg.create_viewport(title='RocketLaunchCountdown', min_width=600, min_height=400, width=600, height=400)
with dpg.font_registry():
# first argument ids the path to the .ttf or .otf file # first argument ids the path to the .ttf or .otf file
default_font = dpg.add_font("OpenSans-Medium.ttf", 128) default_font = dpg.add_font("OpenSans-Medium.ttf", 128)
second_font = dpg.add_font("OpenSans-Medium.ttf", 36) second_font = dpg.add_font("OpenSans-Medium.ttf", 36)
with dpg.window(tag="Primary Window"): with dpg.window(tag="Primary Window"):
timer = 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() dpg.add_separator()
with dpg.group(horizontal=True): with dpg.group(horizontal=True):
@@ -23,7 +41,7 @@ if __name__ == '__main__':
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=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="Minutes")
dpg.add_input_int(min_value=0, max_value=59, min_clamped=True, max_clamped=True, step=0, tag="Seconds") 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=toggleDate)
with dpg.group(horizontal=True): 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=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") dpg.add_input_int(min_value=1, max_value=12, min_clamped=True, max_clamped=True, step=0, tag="Month")
@@ -38,28 +56,30 @@ if __name__ == '__main__':
with dpg.tooltip("Seconds"): with dpg.tooltip("Seconds"):
dpg.add_text("Seconds") dpg.add_text("Seconds")
with dpg.tooltip("Day"): with dpg.tooltip("Day", tag="dayTooltip"):
dpg.add_text("Day") dpg.add_text("Day")
with dpg.tooltip("Month"): with dpg.tooltip("Month", tag="monthTooltip"):
dpg.add_text("Month") dpg.add_text("Month")
with dpg.tooltip("Year"): with dpg.tooltip("Year", tag="yearTooltip"):
dpg.add_text("Year") dpg.add_text("Year")
dpg.bind_font(second_font) dpg.bind_font(second_font)
dpg.bind_item_font(timer, default_font) dpg.bind_item_font(timer, default_font)
dpg.show_metrics() dpg.show_metrics()
dpg.setup_dearpygui() dpg.setup_dearpygui()
dpg.show_viewport() dpg.show_viewport()
dpg.set_primary_window("Primary Window", True) dpg.set_primary_window("Primary Window", True)
currentViewportSize = 0 currentViewportSize = 0
seccondPassed = 0 seccondPassed = 0
dateInputVisable = True
while dpg.is_dearpygui_running(): # on every frame
while dpg.is_dearpygui_running(): # on every frame
if not dpg.get_viewport_client_width() == currentViewportSize: # has it been resized if not dpg.get_viewport_client_width() == currentViewportSize: # has it been resized
currentViewportSize = dpg.get_viewport_client_width() currentViewportSize = dpg.get_viewport_client_width()
dpg.configure_item("text item", width=int(currentViewportSize - 16)) dpg.configure_item("text item", width=int(currentViewportSize - 16))
@@ -89,16 +109,4 @@ if __name__ == '__main__':
dpg.render_dearpygui_frame() dpg.render_dearpygui_frame()
dpg.destroy_context() dpg.destroy_context()
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)