windowInfo = cefpython.WindowInfo()
windowInfo.SetAsPopup(self.browser.GetWindowHandle(), "transparent")
windowInfo.SetTransparentPainting(True)
cefpython.CreateBrowserSync(windowInfo, browserSettings={},
navigateUrl=GetApplicationPath("cefsimple.html"))Can I get a main transparent window(not a popup window) ?
Any possibility to make the background totally invisible(not Aero glass)
so I can create a shaped window?
And is this transparent effect windows only?
WS_TILED.hWnd = cefwindow.CreateWindow(
title="CefSimple", className="cefsimple", width=800, height=600,
icon="icon.ico", windowProc=wndproc)
windowInfo = cefpython.WindowInfo()
windowInfo.SetAsChild(hWnd)
#windowInfo.SetTransparentPainting(True)
#windowInfo.SetAsOffscreen(hWnd)
browser = cefpython.CreateBrowserSync(
windowInfo, browserSettings={},
navigateUrl=GetApplicationPath("cefsimple.html"))
wndStyle = win32gui.GetWindowLong(hWnd,win32con.GWL_STYLE)
win32gui.SetWindowLong(hWnd, win32con.GWL_STYLE, wndStyle|(~win32con.WS_TILED)) #It didn't work!
#win32gui.SetWindowLong(hWnd, win32con.GWL_STYLE, wndStyle|(~win32con.WS_MAXIMIZE)) #It didn't work!
exStyle = win32gui.GetWindowLong(hWnd,win32con.GWL_EXSTYLE)
win32gui.SetWindowLong(hWnd, win32con.GWL_EXSTYLE, exStyle|win32con.WS_EX_LAYERED)
win32gui.SetLayeredWindowAttributes(hWnd, 0, 200, win32con.LWA_ALPHA) #Not what I want;It make everything transparent,not only the background.
cefpython.MessageLoop()
cefpython.Shutdown()
wndStyle & ~(win32con.WS_TILED)
win32gui.SetWindowLong(hWnd, win32con.GWL_STYLE, wndStyle &~ (win32con.WS_TILED)) )
win32gui.SetWindowPos(hWnd,win32con.HWND_TOP,100,100,800,600,win32con.SWP_FRAMECHANGED)add this add:
win32gui.SetWindowLong(windowID, win32con.GWL_EXSTYLE, win32con.WS_EX_LAYERED)
win32gui.SetLayeredWindowAttributes(windowID, 0, 128, win32con.LWA_ALPHA)
Another approach I heard of is sort of a trick.
Take a screenshot of the desktop and use that as your window background, adjusting for your window-size and position of course.
same as before, after line 120 in cefwindow.py:
win32gui.SetWindowLong(windowID, win32con.GWL_EXSTYLE, win32con.WS_EX_LAYERED)
win32gui.SetLayeredWindowAttributes(windowID, win32api.RGB(255,255,255), 0, win32con.LWA_COLORKEY)
== Transparent Everything ==
We set an opacity level and the whole window follows that.
- after line 120 in cefwindow.py after: windowID = win32gui.CreateWindow(...)
win32gui.SetWindowLong(windowID, win32con.GWL_EXSTYLE, win32con.WS_EX_LAYERED)
win32gui.SetLayeredWindowAttributes(windowID, 0, 128, win32con.LWA_ALPHA)
--------------------------------
== Transparent Background ==
This works by making a certain color into a color key, and that color becomes transparent and click through. In this example, white. After setting the Alpha, we need to run SetWindowPos to get the title bar to work, although only the right side can move the window.
- after line 120 in cefwindow.py after: windowID = win32gui.CreateWindow(...)
win32gui.SetWindowLong(windowID, win32con.GWL_EXSTYLE, win32con.WS_EX_LAYERED)
win32gui.SetLayeredWindowAttributes(windowID, win32api.RGB(255,255,255), 0, win32con.LWA_COLORKEY)
(left, top, right, bottom) = (200, 200, 1400, 900) # your window size
win32gui.SetWindowPos(windowID, None, left, top, right-left, bottom-top, win32con.SWP_NOMOVE | win32con.SWP_NOACTIVATE | win32con.SWP_FRAMECHANGED)
--------------------------------
== Transparent Background, no borders or captions ==
Here we need to modify win32gui.CreateWindow() to be a WS_POPUP, and for the transparency we use the white color key.
- around line 120 in cefwindow.py which starts: windowID = win32gui.CreateWindow(...)
- replace "WS_OVERLAPPEDWINDOW | win32con.WS_CLIPCHILDREN" with win32con.WS_POPUP
- After line 120: