2018-09-04 18:40:16 +00:00
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
2018-09-23 16:16:50 +00:00
|
|
|
sg.ChangeLookAndFeel('LightGreen')
|
|
|
|
sg.SetOptions(element_padding=(0, 0))
|
2018-09-04 18:40:16 +00:00
|
|
|
|
2018-09-23 16:16:50 +00:00
|
|
|
# ------ Menu Definition ------ #
|
|
|
|
menu_def = [['File', ['Open', 'Save', 'Exit' ]],
|
|
|
|
['Edit', ['Paste', ['Special', 'Normal', ], 'Undo'], ],
|
|
|
|
['Help', 'About...'], ]
|
2018-09-04 18:40:16 +00:00
|
|
|
|
2018-09-23 16:16:50 +00:00
|
|
|
# ------ GUI Defintion ------ #
|
|
|
|
layout = [
|
|
|
|
[sg.Menu(menu_def)],
|
|
|
|
[sg.Output(size=(60, 20))]
|
|
|
|
]
|
|
|
|
|
|
|
|
form = sg.FlexForm("Windows-like program", default_element_size=(12, 1), auto_size_text=False, auto_size_buttons=False,
|
|
|
|
default_button_element_size=(12, 1)).Layout(layout)
|
|
|
|
|
|
|
|
# ------ Loop & Process button menu choices ------ #
|
2018-09-04 18:40:16 +00:00
|
|
|
while True:
|
|
|
|
button, values = form.Read()
|
2018-09-23 16:16:50 +00:00
|
|
|
if button == None or button == 'Exit':
|
|
|
|
break
|
|
|
|
print('Button = ', button)
|
|
|
|
# ------ Process menu choices ------ #
|
|
|
|
if button == 'About...':
|
|
|
|
sg.Popup('About this program', 'Version 1.0', 'PySimpleGUI rocks...')
|
|
|
|
elif button == 'Open':
|
|
|
|
filename = sg.PopupGetFile('file to open', no_window=True)
|
|
|
|
print(filename)
|