From 371ff39dcb4d77ec12891ce2ca63d9c7ed4c5272 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Mon, 12 Apr 2021 15:46:39 -0400 Subject: [PATCH 1/2] Removed very old timer demo. The same timer is now in the Demo_Desktop_Widget_Timer.py --- DemoPrograms/Demo_Timer.py | 41 -------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 DemoPrograms/Demo_Timer.py diff --git a/DemoPrograms/Demo_Timer.py b/DemoPrograms/Demo_Timer.py deleted file mode 100644 index 9f10eab5..00000000 --- a/DemoPrograms/Demo_Timer.py +++ /dev/null @@ -1,41 +0,0 @@ -import PySimpleGUI as sg -import time - -# Basic timer in PSG - -def Timer(): - sg.theme('Dark') - sg.set_options(element_padding=(0, 0)) - form_rows = [[sg.Text(size=(8, 2), font=('Helvetica', 20), - justification='center', key='text')], - [sg.Button('Pause', key='-RUN-PAUSE-'), - sg.Button('Reset'), - sg.Exit(button_color=('white', 'firebrick4'))]] - window = sg.Window('Running Timer', form_rows, - no_titlebar=True, auto_size_buttons=False) - i = 0 - paused = False - start_time = int(round(time.time() * 100)) - - while True: - # This is the code that reads and updates your window - button, values = window.read(timeout=10) - window['text'].update('{:02d}:{:02d}.{:02d}'.format( - (i // 100) // 60, (i // 100) % 60, i % 100)) - - if values is None or button == 'Exit': - break - - if button == 'Reset': - i = 0 - - elif button == '-RUN-PAUSE-': - paused = not paused - window['-RUN-PAUSE-'].update('Run' if paused else 'Pause') - - if not paused: - i += 1 - - window.close() - -Timer() From 3660451c9c8460429f33a2731737ff063cbd8de4 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Mon, 12 Apr 2021 15:50:52 -0400 Subject: [PATCH 2/2] Right click menu added as a way to edit the program. --- DemoPrograms/Demo_Desktop_Widget_Timer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DemoPrograms/Demo_Desktop_Widget_Timer.py b/DemoPrograms/Demo_Desktop_Widget_Timer.py index d4cede91..f78f4d5d 100644 --- a/DemoPrograms/Demo_Desktop_Widget_Timer.py +++ b/DemoPrograms/Demo_Desktop_Widget_Timer.py @@ -1,4 +1,5 @@ #!/usr/bin/env python + import PySimpleGUI as sg import time @@ -12,6 +13,7 @@ import time this design were not used, then the time value displayed would slowly drift by the amount of time it takes to execute the PySimpleGUI read and update calls (not good!) + Copyright 2021 PySimpleGUI """ @@ -34,7 +36,8 @@ window = sg.Window('Running Timer', layout, auto_size_buttons=False, keep_on_top=True, grab_anywhere=True, - element_padding=(0, 0)) + element_padding=(0, 0), finalize=True, + right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_EXIT) current_time, paused_time, paused = 0, 0, False start_time = time_as_int() @@ -60,7 +63,8 @@ while True: start_time = start_time + time_as_int() - paused_time # Change button's text window['-RUN-PAUSE-'].update('Run' if paused else 'Pause') - + elif event == 'Edit Me': + sg.execute_editor(__file__) # --------- Display timer in window -------- window['text'].update('{:02d}:{:02d}.{:02d}'.format((current_time // 100) // 60, (current_time // 100) % 60,