X Tutup
Skip to content

Commit 3364c8f

Browse files
committed
Add window_size.py snippet
1 parent c160430 commit 3364c8f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

examples/snippets/window_size.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Set initial size of window to 900px / 640px without using
3+
any third party GUI framework. On Linux/Mac you can set
4+
window size by calling WindowInfo.SetAsChild. On Windows
5+
you can accomplish this by calling Windows native functions
6+
using the ctypes module.
7+
"""
8+
9+
from cefpython3 import cefpython as cef
10+
import platform
11+
12+
13+
def main():
14+
cef.Initialize()
15+
window_info = cef.WindowInfo()
16+
window_info.SetAsChild(0, [0, 0, 900, 640])
17+
browser = cef.CreateBrowserSync(url="https://www.google.com/",
18+
window_info=window_info,
19+
window_title="Window size")
20+
if platform.system() == "Windows":
21+
pass
22+
cef.MessageLoop()
23+
del browser
24+
cef.Shutdown()
25+
26+
27+
class LifespanHandler(object):
28+
def OnBeforeClose(self, browser):
29+
print("Browser ID: {}".format(browser.GetIdentifier()))
30+
print("Browser will close and app will exit")
31+
32+
33+
if __name__ == '__main__':
34+
main()

0 commit comments

Comments
 (0)
X Tutup