-
-
Notifications
You must be signed in to change notification settings - Fork 602
Description
Specification
- pywebview version: 3.4
- operating system: Windows 10
- web renderer: Unknown - whatever is the default
Description
I use pywebview along with pystray (0.17.3) as part of a script that occasionally needs to pop up a login window. Because both pywebview and pystray need to run on the main thread, I open the webview from a click on the system tray icon, as shown in the basic example below. This action runs on the main thread, and on macOS and Ubuntu it works with no issues. On Windows it gives the following error:
Unhandled Exception: Python.Runtime.PythonException: OSError : [WinError 1402] Invalid cursor handle.
at Python.Runtime.Dispatcher.Dispatch(ArrayList args)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
A minimum example to demonstrate the issue is given below. Run this code on Windows and you will see a black square appear in the system tray. Right-click the icon and click the Webview option to trigger the crash. I've also added the thread names to show that both pystray and pywebview are running on the main thread:
import pystray, webview, threading
from PIL import Image
def click(icon, item):
print('pywebview thread:', threading.current_thread().__class__.__name__)
window = webview.create_window('Woah dude!', 'https://pywebview.flowrl.com')
webview.start()
if __name__ == '__main__':
print('pystray thread:', threading.current_thread().__class__.__name__)
pystray.Icon('test', Image.new('RGB', (16, 16)), menu=pystray.Menu(pystray.MenuItem('Webview', click))).run()
Practicalities
-
YES/NO I am willing to work on this issue myself.
Possibly, if you can point to where to begin -
YES/NO I am prepared to support this issue financially.
If needed