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

@ -0,0 +1,43 @@
#!/usr/bin/env python
import sys
if sys.version_info[0] >= 3:
import PySimpleGUI as sg
else:
import PySimpleGUI27 as sg
"""
Demo Button Function Calls
Typically GUI packages in Python (tkinter, Qt, WxPython, etc) will call a user's function
when a button is clicked. This "Callback" model versus "Message Passing" model is a fundamental
difference between PySimpleGUI and all other GUI.
There are NO BUTTON CALLBACKS in the PySimpleGUI Architecture
It is quite easy to simulate these callbacks however. The way to do this is to add the calls
to your Event Loop
"""
def callback_function1():
sg.Popup('In Callback Function 1')
print('In the callback function 1')
def callback_function2():
sg.Popup('In Callback Function 2')
print('In the callback function 2')
layout = [ [sg.Text('Demo of Button Callbacks')],
[sg.Button('Button 1'), sg.Button('Button 2')] ]
window = sg.Window('Button Callback Simulation').Layout(layout)
while True: # Event Loop
event, values = window.Read()
if event is None:
break
elif event == 'Button 1':
callback_function1() # call the "Callback" function
elif event == 'Button 2':
callback_function2() # call the "Callback" function
window.Close()