forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow_size.py
More file actions
33 lines (28 loc) · 1020 Bytes
/
window_size.py
File metadata and controls
33 lines (28 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Set initial window size to 900/640px without use of
any third party GUI framework. On Linux/Mac you can set
window size by calling WindowInfo.SetAsChild. On Windows
you can accomplish this by calling Windows native functions
using the ctypes module.
"""
from cefpython3 import cefpython as cef
import ctypes
import platform
def main():
cef.Initialize()
window_info = cef.WindowInfo()
parent_handle = 0
# SetAsChild() call has effect only on Mac and Linux.
# All rect coordinates are applied including X and Y parameters.
window_info.SetAsChild(parent_handle, [0, 0, 900, 640])
browser = cef.CreateBrowserSync(url="https://www.google.com/",
window_info=window_info,
window_title="Window size")
if platform.system() == "Windows":
# X and Y parameters are ignored.
browser.SetBounds(0, 0, 900, 640)
cef.MessageLoop()
del browser
cef.Shutdown()
if __name__ == '__main__':
main()