X Tutup
Skip to content

Commit 39ca247

Browse files
committed
Update window_size.py snippet
1 parent f6e7de2 commit 39ca247

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

examples/README-examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ See small code snippets that show various CEF features in the
6464
- [onpagecomplete.py](snippets/onpagecomplete.py) - Execute custom
6565
Python code on a web page when page loading is complete.
6666
- [window_size.py](snippets/window_size.py) - Set initial window size
67-
without using any third party GUI framework.
67+
without use of any third party GUI framework.
6868

6969

7070
### GUI frameworks

examples/snippets/window_size.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Set initial window size to 900/600 pixels without using
2+
Set initial window size to 900/640px without use of
33
any third party GUI framework. On Linux/Mac you can set
44
window size by calling WindowInfo.SetAsChild. On Windows
55
you 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-
4237
if __name__ == '__main__':
4338
main()

0 commit comments

Comments
 (0)
X Tutup