diff --git a/Demo_Design_Patterns.py b/Demo_Design_Patterns.py new file mode 100644 index 00000000..1f054245 --- /dev/null +++ b/Demo_Design_Patterns.py @@ -0,0 +1,31 @@ +# DESIGN PATTERN 1 - Simple Window +import PySimpleGUI as sg + +layout = [[ sg.Text('My layout') ]] + +window = sg.Window('My window').Layout(layout) +button, value = window.Read() + +# DESIGN PATTERN 2 - Persistent Window +import PySimpleGUI as sg + +layout = [[ sg.Text('My layout') ]] + +window = sg.Window('My new window').Layout(layout) + +while True: # Event Loop + button, value = window.Read() + if button is None: + break + +# DESIGN PATTERN 3 - Persistent Window with "early update" required +import PySimpleGUI as sg + +layout = [[ sg.Text('My layout') ]] + +window = sg.Window('My new window').Layout(layout).Finalize() + +while True: # Event Loop + button, value = window.Read() + if button is None: + break \ No newline at end of file diff --git a/Demo_Graph_Element.py b/Demo_Graph_Element.py index da50d3ae..9b831690 100644 --- a/Demo_Graph_Element.py +++ b/Demo_Graph_Element.py @@ -29,10 +29,8 @@ def main(): layout = [ [sg.T('Ping times to Google.com', font='Any 12'), sg.Quit(pad=((100,0), 0), button_color=('white', 'black'))], [sg.Graph(CANVAS_SIZE, (0,0), (SAMPLES,500),background_color='black', key='graph')],] - window = sg.Window('Canvas test', grab_anywhere=True, background_color='black', no_titlebar=False, use_default_focus=False) - window.Layout(layout) + window = sg.Window('Canvas test', grab_anywhere=True, background_color='black', no_titlebar=False, use_default_focus=False).Layout(layout) - window.Finalize() graph = window.FindElement('graph') prev_response_time = None