DEMO WITH SUGGESTED DESIGN PATTERNS
This commit is contained in:
parent
a1f4c60271
commit
7b0a6be951
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue