Skip to content

Commit 86f77b7

Browse files
committed
Fix r0x0r#29: Packaging with PyInstaller: Icon not found
1 parent 75cdaf8 commit 86f77b7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

webview/win32.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ def _register_window(self):
9595
self.wndclass.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW
9696
self.wndclass.lpfnWndProc = message_map
9797
self.wndclass.hInstance = win32api.GetModuleHandle()
98-
self.wndclass.hIcon = win32gui.LoadIcon(self.wndclass.hInstance, 1)
9998
self.wndclass.hCursor = win32gui.LoadCursor(win32con.NULL, win32con.IDC_ARROW)
10099
self.wndclass.hbrBackground = win32gui.GetStockObject(win32con.WHITE_BRUSH)
101100
self.wndclass.lpszMenuName = ""
102101
self.wndclass.lpszClassName = "MainWin"
103102

103+
try: # Try loading an icon embedded in the exe file. This will when frozen with PyInstaller
104+
self.wndclass.hIcon = win32gui.LoadIcon(self.wndclass.hInstance, 1)
105+
except:
106+
pass
107+
104108
# Register Window Class
105109
if not win32gui.RegisterClass(self.wndclass):
106110
raise WinError()
@@ -177,7 +181,7 @@ def show(self):
177181
win32gui.UpdateWindow(self.atlhwnd)
178182
win32gui.SetFocus(self.atlhwnd)
179183

180-
# Pump messages
184+
# Start sending and receiving messages
181185
win32gui.PumpMessages()
182186

183187
def destroy(self):

0 commit comments

Comments
 (0)