Major update of all demo programs to use new PEP8 bindings, etc

This commit is contained in:
PySimpleGUI 2019-10-23 16:10:03 -04:00
parent 3f7c87c562
commit 7f52778bcc
307 changed files with 19546 additions and 3297 deletions

View file

@ -6,6 +6,8 @@ import PySimpleGUI as sg
Check out the variable menu_def for a hint on how to
define menus
"""
def second_window():
layout = [[sg.Text('The second form is small \nHere to show that opening a window using a window works')],
@ -15,23 +17,24 @@ def second_window():
event, values = window.read()
window.close()
def test_menus():
def test_menus():
sg.change_look_and_feel('LightGreen')
sg.set_options(element_padding=(0, 0))
# ------ Menu Definition ------ #
menu_def = [['&File', ['&Open', '&Save', '&Properties', 'E&xit' ]],
['&Edit', ['&Paste', ['Special', 'Normal',], 'Undo'],],
['&Toolbar', ['---', 'Command &1', 'Command &2', '---', 'Command &3', 'Command &4']],
['&Help', '&About...'],]
menu_def = [['&File', ['&Open', '&Save', '&Properties', 'E&xit']],
['&Edit', ['&Paste', ['Special', 'Normal', ], 'Undo'], ],
['&Toolbar', ['---', 'Command &1', 'Command &2',
'---', 'Command &3', 'Command &4']],
['&Help', '&About...'], ]
# ------ GUI Defintion ------ #
layout = [
[sg.Menu(menu_def, tearoff=False, pad=(20,1))],
[sg.Output(size=(60,20))],
]
[sg.Menu(menu_def, tearoff=False, pad=(20, 1))],
[sg.Output(size=(60, 20))],
]
window = sg.Window("Windows-like program",
layout,
@ -43,13 +46,14 @@ def test_menus():
# ------ Loop & Process button menu choices ------ #
while True:
event, values = window.read()
if event is None or event == 'Exit':
if event in (None, 'Exit'):
return
print('Event = ', event)
# ------ Process menu choices ------ #
if event == 'About...':
window.disappear()
sg.popup('About this program','Version 1.0', 'PySimpleGUI rocks...', grab_anywhere=True)
sg.popup('About this program', 'Version 1.0',
'PySimpleGUI rocks...', grab_anywhere=True)
window.reappear()
elif event == 'Open':
filename = sg.popup_get_file('file to open', no_window=True)
@ -57,4 +61,7 @@ def test_menus():
elif event == 'Properties':
second_window()
test_menus()
window.close()
test_menus()