I'm trying to make a window which wants to be frameless (Is option in pywebview too but I can't minimize from windows taskbar) with custom menu like Spotify (for example) the idea is working succesfully but after minimze from windows taskbar and press on it back actual window is getting bigger mysteriously
import win32con
import win32gui
import webview
import ctypes
def on_loaded():
print('DOM is ready')
window.show()
window_handle = ctypes.windll.user32.FindWindowW(None, "Test")
current_style = ctypes.windll.user32.GetWindowLongPtrW(window_handle, win32con.GWL_STYLE)
new_style = current_style & ~win32con.WS_CAPTION & ~win32con.WS_SYSMENU & ~win32con.WS_BORDER
new_style |= win32con.WS_POPUP
ctypes.windll.user32.SetWindowLongPtrW(window_handle, win32con.GWL_STYLE, new_style)
ex_style = ctypes.windll.user32.GetWindowLongPtrW(window_handle, win32con.GWL_EXSTYLE)
ctypes.windll.user32.SetWindowLongPtrW(window_handle, win32con.GWL_EXSTYLE, ex_style | 0x80000000)
webview.windows[0].events.loaded -= on_loaded
def on_resized(width, height):
print(
'pywebview window is resized. new dimensions are {width} x {height}'.format(
width=width, height=height
)
)
if __name__ == '__main__':
window = webview.create_window(
'Test', html='<html><head></head><body><h1>Test application</body></html>', hidden=True
)
window.events.loaded += on_loaded
window.events.resized += on_resized
webview.start()
After running that everything works fine but after minimize from windows taskbar and bring it back it trigger resize event with these messages
pywebview window is resized. new dimensions are 800 x 600
pywebview window is resized. new dimensions are 160 x 28
pywebview window is resized. new dimensions are 800 x 600
pywebview window is resized. new dimensions are 802 x 625
pywebview window is resized. new dimensions are 160 x 28
pywebview window is resized. new dimensions are 802 x 625
pywebview window is resized. new dimensions are 804 x 650
pywebview window is resized. new dimensions are 160 x 28
I can resize it with window.resize(800, 600) in resize event but I don't think it's the best fix