11"""
2- Set initial window size to 900/600 pixels without using
2+ Set initial window size to 900/640px without use of
33any third party GUI framework. On Linux/Mac you can set
44window size by calling WindowInfo.SetAsChild. On Windows
55you can accomplish this by calling Windows native functions
@@ -15,16 +15,17 @@ def main():
1515 cef .Initialize ()
1616 window_info = cef .WindowInfo ()
1717 parent_handle = 0
18- # All rect coordinates are applied including X and Y parameters
18+ # This call has effect only on Mac and Linux.
19+ # All rect coordinates are applied including X and Y parameters.
1920 window_info .SetAsChild (parent_handle , [0 , 0 , 900 , 640 ])
2021 browser = cef .CreateBrowserSync (url = "https://www.google.com/" ,
2122 window_info = window_info ,
2223 window_title = "Window size" )
2324 if platform .system () == "Windows" :
2425 window_handle = browser .GetOuterWindowHandle ()
26+ insert_after_handle = 0
2527 # X and Y parameters are ignored by setting the SWP_NOMOVE flag
2628 SWP_NOMOVE = 0x0002
27- insert_after_handle = 0
2829 # noinspection PyUnresolvedReferences
2930 ctypes .windll .user32 .SetWindowPos (window_handle , insert_after_handle ,
3031 0 , 0 , 900 , 640 , SWP_NOMOVE )
@@ -33,11 +34,5 @@ def main():
3334 cef .Shutdown ()
3435
3536
36- class LifespanHandler (object ):
37- def OnBeforeClose (self , browser ):
38- print ("Browser ID: {}" .format (browser .GetIdentifier ()))
39- print ("Browser will close and app will exit" )
40-
41-
4237if __name__ == '__main__' :
4338 main ()
0 commit comments