And updated version of the "Edit Me" right menu design pattern
This commit is contained in:
parent
7da029ebf8
commit
f3270e00ec
|
@ -1,7 +1,7 @@
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Demo "Edit Me"
|
Demo "Edit Me" (and Version)
|
||||||
|
|
||||||
More and more of these Demos are getting an "Edit me" option added.
|
More and more of these Demos are getting an "Edit me" option added.
|
||||||
|
|
||||||
|
@ -12,20 +12,18 @@ import PySimpleGUI as sg
|
||||||
You can add this capability to your program by adding a right click menu to your window and calling the
|
You can add this capability to your program by adding a right click menu to your window and calling the
|
||||||
editor that you set up in the global PySimpleGUI options.
|
editor that you set up in the global PySimpleGUI options.
|
||||||
|
|
||||||
You need to do 2 things to make this work:
|
A constant MENU_RIGHT_CLICK_EDITME_VER_EXIT, when set at the right click menu shows a "Version" and "Edit Me" meny item.
|
||||||
1. Add a right click menu - requires you to add 1 parameter to your Window creation
|
|
||||||
2. Add 1 if statement to your event loop.
|
|
||||||
|
|
||||||
You will need to have first set up your editor by using the menu in sg.main()
|
You will need to have first set up your editor by using the menu in sg.main()
|
||||||
|
|
||||||
Copyright 2021 PySimpleGUI.org
|
Copyright 2021, 2022, 2023 PySimpleGUI.org
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
layout = [[sg.Text('Edit this program by right clicking and choosing "Edit me"')],
|
layout = [[sg.Text('Edit this program by right clicking and choosing "Edit me"')],
|
||||||
[sg.Button('Exit')]]
|
[sg.Button('Exit')]]
|
||||||
|
|
||||||
window = sg.Window('Edit Me Right Click Menu Demo', layout, right_click_menu=[[''], ['Edit Me', 'Exit',]])
|
window = sg.Window('Edit Me Right Click Menu Demo', layout, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT)
|
||||||
|
|
||||||
while True: # Event Loop
|
while True: # Event Loop
|
||||||
event, values = window.read()
|
event, values = window.read()
|
||||||
|
@ -33,5 +31,7 @@ while True: # Event Loop
|
||||||
break
|
break
|
||||||
if event == 'Edit Me':
|
if event == 'Edit Me':
|
||||||
sg.execute_editor(__file__)
|
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()
|
window.close()
|
||||||
|
|
Loading…
Reference in New Issue