gpt4 book ai didi

python - CEF Python 隐藏浏览器

转载 作者:太空宇宙 更新时间:2023-11-03 21:17:17 29 4
gpt4 key购买 nike

我创建一个浏览器:

browser = cef.CreateBrowserSync(url=os.path.dirname(os.path.abspath(__file__))+'\\gui.html', window_title="标题")

有什么办法可以随时隐藏和显示窗口吗?

最佳答案

如果您使用“wxpython.py”示例,则可以调用 MainFrame.Hide() 来隐藏窗口,并调用 Show() 来显示它。

如果使用“hello_world.py”示例,那么您需要使用 ctypes 等进行 native 操作系统调用。对于 Windows,代码为:

import ctypes
SW_SHOW = 5
SW_HIDE = 0
hwnd = browser.GetWindowHandle()
ctypes.windll.user32.ShowWindow(hwnd, SW_HIDE)
ctypes.windll.user32.ShowWindow(hwnd, SW_SHOW)

关于python - CEF Python 隐藏浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54594738/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com