From 0b911c451c3f64439782acb94aef34e41c21e1d1 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sun, 12 Jun 2022 17:44:14 -0400 Subject: [PATCH] Addition of the standard "edit me" and "versions" right click menu --- DemoPrograms/Demo_Desktop_Widget_CPU_Gauge.py | 4 +++- DemoPrograms/Demo_Desktop_Widget_CPU_Square.py | 4 +++- DemoPrograms/Demo_Desktop_Widget_RAM_Gauge.py | 4 +++- DemoPrograms/Demo_Desktop_Widget_RAM_Square.py | 6 ++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/DemoPrograms/Demo_Desktop_Widget_CPU_Gauge.py b/DemoPrograms/Demo_Desktop_Widget_CPU_Gauge.py index 97b164ce..c4748172 100644 --- a/DemoPrograms/Demo_Desktop_Widget_CPU_Gauge.py +++ b/DemoPrograms/Demo_Desktop_Widget_CPU_Gauge.py @@ -274,7 +274,7 @@ def main(location): [sg.T(size=(5, 1), font='Any 20', justification='c', background_color='black', k='-gauge VALUE-')]] - window = sg.Window('CPU Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, background_color='black', element_justification='c', finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_EXIT, enable_close_attempted_event=True) + window = sg.Window('CPU Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, background_color='black', element_justification='c', finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT, enable_close_attempted_event=True) gauge = Gauge(pointer_color=sg.theme_text_color(), clock_color=sg.theme_text_color(), major_tick_color=sg.theme_text_color(), minor_tick_color=sg.theme_input_background_color(), pointer_outer_color=sg.theme_text_color(), major_tick_start_radius=45, @@ -298,6 +298,8 @@ def main(location): break if event == 'Edit Me': sg.execute_editor(__file__) + elif event == 'Version': + sg.popup_scrolled(__file__, sg.get_versions(), location=window.current_location(), keep_on_top=True, non_blocking=True) window.close() diff --git a/DemoPrograms/Demo_Desktop_Widget_CPU_Square.py b/DemoPrograms/Demo_Desktop_Widget_CPU_Square.py index c4636477..866b1bac 100644 --- a/DemoPrograms/Demo_Desktop_Widget_CPU_Square.py +++ b/DemoPrograms/Demo_Desktop_Widget_CPU_Square.py @@ -23,7 +23,7 @@ def main(location): layout = [[graph]] - window = sg.Window('CPU Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_EXIT, enable_close_attempted_event=True) + window = sg.Window('CPU Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT, enable_close_attempted_event=True) text_id2 = graph.draw_text(f'CPU', (GSIZE[0] // 2, GSIZE[1] // 4), font='Any 20', text_location=sg.TEXT_LOCATION_CENTER, color=sg.theme_button_color()[0]) @@ -46,6 +46,8 @@ def main(location): break if event == 'Edit Me': sg.execute_editor(__file__) + elif event == 'Version': + sg.popup_scrolled(__file__, sg.get_versions(), location=window.current_location(), keep_on_top=True, non_blocking=True) # erase figures so they can be redrawn graph.delete_figure(rect_id) graph.delete_figure(text_id1) diff --git a/DemoPrograms/Demo_Desktop_Widget_RAM_Gauge.py b/DemoPrograms/Demo_Desktop_Widget_RAM_Gauge.py index 747c550f..bee05dc5 100644 --- a/DemoPrograms/Demo_Desktop_Widget_RAM_Gauge.py +++ b/DemoPrograms/Demo_Desktop_Widget_RAM_Gauge.py @@ -275,7 +275,7 @@ def main(location): [sg.T(size=(8, 1), font='Any 14', justification='c', background_color='black', k='-RAM USED-')], ] - window = sg.Window('CPU Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, background_color='black', element_justification='c', finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_EXIT) + window = sg.Window('CPU Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, background_color='black', element_justification='c', finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT) gauge = Gauge(pointer_color=sg.theme_text_color(), clock_color=sg.theme_text_color(), major_tick_color=sg.theme_text_color(), minor_tick_color=sg.theme_input_background_color(), pointer_outer_color=sg.theme_text_color(), major_tick_start_radius=45, @@ -302,6 +302,8 @@ def main(location): break if event == 'Edit Me': sg.execute_editor(__file__) + elif event == 'Version': + sg.popup_scrolled(__file__, sg.get_versions(), location=window.current_location(), keep_on_top=True, non_blocking=True) window.close() diff --git a/DemoPrograms/Demo_Desktop_Widget_RAM_Square.py b/DemoPrograms/Demo_Desktop_Widget_RAM_Square.py index 3d1836b5..440170df 100644 --- a/DemoPrograms/Demo_Desktop_Widget_RAM_Square.py +++ b/DemoPrograms/Demo_Desktop_Widget_RAM_Square.py @@ -30,7 +30,7 @@ def main(location): graph = sg.Graph(GSIZE, (0, 0), GSIZE, key='-GRAPH-', enable_events=True) layout = [[graph]] - window = sg.Window('RAM Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_EXIT, enable_close_attempted_event=True) + window = sg.Window('RAM Usage Widget Square', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_padding=(0, 0), alpha_channel=ALPHA, finalize=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT, enable_close_attempted_event=True, keep_on_top=True) while True: # Event Loop @@ -47,8 +47,10 @@ def main(location): if event != sg.WIN_CLOSED: sg.user_settings_set_entry('-location-', window.current_location()) # The line of code to save the position before exiting break - elif event == 'Edit Me': + if event == 'Edit Me': sg.execute_editor(__file__) + elif event == 'Version': + sg.popup_scrolled(__file__, sg.get_versions(), location=window.current_location(), keep_on_top=True, non_blocking=True) graph.delete_figure(rect_id) graph.delete_figure(text_id1)