@@ -860,8 +860,7 @@ While it's fun to scribble on a Canvas Widget, try Graph Element makes it a down
860860 [sg.T(' Change circle color to:' ), sg.Button(' Red' ), sg.Button(' Blue' )]
861861 ]
862862
863- window = sg.Window(' Canvas test' )
864- window.Layout(layout)
863+ window = sg.Window(' Canvas test' , layout)
865864 window.Finalize()
866865
867866 canvas = window.FindElement(' canvas' )
@@ -891,8 +890,7 @@ Just like you can draw on a tkinter widget, you can also draw on a Graph Element
891890 [sg.T(' Change circle color to:' ), sg.Button(' Red' ), sg.Button(' Blue' ), sg.Button(' Move' )]
892891 ]
893892
894- window = sg.Window(' Graph test' )
895- window.Layout(layout)
893+ window = sg.Window(' Graph test' , layout)
896894 window.Finalize()
897895
898896 graph = window.FindElement(' graph' )
@@ -952,7 +950,7 @@ There are a number of features used in this Recipe including:
952950 [sg.Text(' ' , size = (15 , 1 ), font = (' Helvetica' , 18 ), text_color = ' red' , key = ' out' )],
953951 ]
954952
955- window = sg.Window(' Keypad' , default_button_element_size = (5 , 2 ), auto_size_buttons = False , grab_anywhere = False ).Layout(layout)
953+ window = sg.Window(' Keypad' , layout, default_button_element_size = (5 , 2 ), auto_size_buttons = False , grab_anywhere = False )
956954
957955 # Loop forever reading the window's values, updating the Input field
958956 keys_entered = ' '
@@ -1005,7 +1003,7 @@ layout = [[sg.Text('Animated Matplotlib', size=(40, 1), justification='center',
10051003# create the window and show it without the plot
10061004
10071005
1008- window = sg.Window(' Demo Application - Embedding Matplotlib In PySimpleGUI' ).Layout( layout)
1006+ window = sg.Window(' Demo Application - Embedding Matplotlib In PySimpleGUI' , layout)
10091007window.Finalize() # needed to access the canvas element prior to reading the window
10101008
10111009canvas_elem = window.FindElement(' canvas' )
@@ -1069,9 +1067,8 @@ In other GUI frameworks this program would be most likely "event driven" with ca
10691067 sg.Button(' Submit' , button_color = (' white' , ' springgreen4' ), key = ' Submit' )]
10701068 ]
10711069
1072- window = sg.Window(" Time Tracker" , default_element_size = (12 ,1 ), text_justification = ' r' , auto_size_text = False , auto_size_buttons = False ,
1070+ window = sg.Window(" Time Tracker" , layout, default_element_size = (12 ,1 ), text_justification = ' r' , auto_size_text = False , auto_size_buttons = False ,
10731071 default_button_element_size = (12 ,1 ))
1074- window.Layout(layout)
10751072 window.Finalize()
10761073 window.FindElement(' Stop' ).Update(disabled = True )
10771074 window.FindElement(' Reset' ).Update(disabled = True )
@@ -1139,8 +1136,8 @@ Use the upper half to generate your hash code. Then paste it into the code in t
11391136 [sg.T(' SHA Hash' ), sg.In(' ' , size = (40 ,1 ), key = ' hash' )],
11401137 ]
11411138
1142- window = sg.Window(' SHA Generator' , auto_size_text = False , default_element_size = (10 ,1 ),
1143- text_justification = ' r' , return_keyboard_events = True , grab_anywhere = False ).Layout(layout)
1139+ window = sg.Window(' SHA Generator' , layout, auto_size_text = False , default_element_size = (10 ,1 ),
1140+ text_justification = ' r' , return_keyboard_events = True , grab_anywhere = False )
11441141
11451142
11461143 while True :
@@ -1236,7 +1233,7 @@ You can easily change colors to match your background by changing a couple of pa
12361233 sg.Button(' EXIT' , button_color = (' white' ,' firebrick3' ))],
12371234 [sg.T(' ' , text_color = ' white' , size = (50 ,1 ), key = ' output' )]]
12381235
1239- window = sg.Window(' Floating Toolbar' , no_titlebar = True , keep_on_top = True ).Layout(layout)
1236+ window = sg.Window(' Floating Toolbar' , layout, no_titlebar = True , keep_on_top = True )
12401237
12411238 # ---===--- Loop taking in user input (events) --- #
12421239 while True :
@@ -1320,7 +1317,7 @@ layout = [[sg.Text('')],
13201317 sg.Button(' Reset' , button_color = (' white' , ' #007339' ), key = ' Reset' ),
13211318 sg.Exit(button_color = (' white' , ' firebrick4' ), key = ' Exit' )]]
13221319
1323- window = sg.Window(' Running Timer' , no_titlebar = True , auto_size_buttons = False , keep_on_top = True , grab_anywhere = True ).Layout(layout )
1320+ window = sg.Window(' Running Timer' , layout, no_titlebar = True , auto_size_buttons = False , keep_on_top = True , grab_anywhere = True )
13241321
13251322# ---------------- main loop ----------------
13261323current_time = 0
@@ -1382,8 +1379,8 @@ layout = [[sg.Text('')],
13821379 [sg.Exit(button_color = (' white' , ' firebrick4' ), pad = ((15 , 0 ), 0 )),
13831380 sg.Spin([x + 1 for x in range (10 )], 1 , key = ' spin' )]]
13841381
1385- window = sg.Window(' Running Timer' , no_titlebar = True , auto_size_buttons = False , keep_on_top = True ,
1386- grab_anywhere = True ).Layout(layout)
1382+ window = sg.Window(' Running Timer' , layout, no_titlebar = True , auto_size_buttons = False , keep_on_top = True ,
1383+ grab_anywhere = True )
13871384
13881385# ---------------- main loop ----------------
13891386while (True ):
@@ -1437,8 +1434,8 @@ If you double click the dashed line at the top of the list of choices, that menu
14371434 [sg.Output(size = (60 , 20 ))]
14381435 ]
14391436
1440- window = sg.Window(" Windows-like program" , default_element_size = (12 , 1 ), auto_size_text = False , auto_size_buttons = False ,
1441- default_button_element_size = (12 , 1 )).Layout(layout)
1437+ window = sg.Window(" Windows-like program" , layout, default_element_size = (12 , 1 ), auto_size_text = False , auto_size_buttons = False ,
1438+ default_button_element_size = (12 , 1 ))
14421439
14431440 # ------ Loop & Process button menu choices ------ #
14441441 while True :
@@ -1470,7 +1467,7 @@ import PySimpleGUI as sg
14701467
14711468layout = [[sg.Graph(canvas_size = (400 , 400 ), graph_bottom_left = (- 105 ,- 105 ), graph_top_right = (105 ,105 ), background_color = ' white' , key = ' graph' , tooltip = ' This is a cool graph!' )],]
14721469
1473- window = sg.Window(' Graph of Sine Function' , grab_anywhere = True ).Layout(layout ).Finalize()
1470+ window = sg.Window(' Graph of Sine Function' , layout, grab_anywhere = True ).Finalize()
14741471graph = window.FindElement(' graph' )
14751472
14761473# Draw axis
@@ -1517,7 +1514,7 @@ tab2_layout = [[sg.T('This is inside tab 2')],
15171514layout = [[sg.TabGroup([[sg.Tab(' Tab 1' , tab1_layout, tooltip = ' tip' ), sg.Tab(' Tab 2' , tab2_layout)]], tooltip = ' TIP2' )],
15181515 [sg.Button(' Read' )]]
15191516
1520- window = sg.Window(' My window with tabs' , default_element_size = (12 ,1 )).Layout(layout )
1517+ window = sg.Window(' My window with tabs' , layout, default_element_size = (12 ,1 ))
15211518
15221519while True :
15231520 event, values = window.Read()
0 commit comments