Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webview doesn't load when I import pystray #486

Closed
alexwohlbruck opened this issue Mar 17, 2020 · 6 comments
Closed

Webview doesn't load when I import pystray #486

alexwohlbruck opened this issue Mar 17, 2020 · 6 comments
Labels

Comments

@alexwohlbruck
Copy link

  • pywebview version: 3.2
  • platform / version: Windows 10

For some reason when I try to use this library with pystray (a library that creates a system tray icon), I get this strange runtime error. I am pulling my hair out trying to get these two modules to work together, but I don't know what this error message is coming from. Only when I import both of the libraries and try to create a new window.

import webview
import pystray
	
window = webview.create_window('Woah dude!', html='<h1>Woah dude!<h1>')
webview.start()
Unhandled Exception: Python.Runtime.PythonException: ArgumentError : argument 1: <class 'OverflowError'>: int too long to convert
   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()

Anybody else getting this on their machines? How can I even begin to debug this?

@r0x0r
Copy link
Owner

r0x0r commented Mar 18, 2020

First of all, this is the first time I heard about pystray. Second, systray feature has been requested many times, so the best course would be to implement into pywebview imo. However, using this library sounds like a viable choice as well.
This error message is not very informative, so it is hard to say whether the problem is in pystray or pywebview. pystray is implemented with pywin32 and pywebview with winforms, so my guess either one sets something that conflicts with the other one. As for how to debug it, I would set breakpoints early in the code of both libraries and see how far it can go. If breakpoint cannot be hit (as in the case of code run in Windows threads), replace breakpoint with print statements and see what is displayed and what is not.
Hopefully this is of help to you.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@AlexCovizzi
Copy link
Contributor

AlexCovizzi commented Nov 29, 2020

Got the same error as OP.
Following @r0x0r suggestion I traced back the error to this 2 lines in winforms.py:

handle = windll.kernel32.GetModuleHandleW(None)
icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0)

After trying some things I was able to solve it by implementing the solution suggested here: Link to Stackoverflow
I'll open a PR with the change

AlexCovizzi added a commit to AlexCovizzi/pywebview that referenced this issue Nov 29, 2020
r0x0r added a commit that referenced this issue Dec 1, 2020
@r0x0r
Copy link
Owner

r0x0r commented Dec 3, 2020

@AlexCovizzi @alexwohlbruck care to add a barebone example that would demonstrate a minimal use of pywebview with pystray?

@alexwohlbruck
Copy link
Author

@r0x0r I don't think i ever got this to work. I have been using the Eel library and it's working well for me!

@r0x0r r0x0r mentioned this issue Dec 3, 2020
Closed
@AlexCovizzi
Copy link
Contributor

AlexCovizzi commented Dec 5, 2020

@r0x0r I opened a pull request with a simple example #670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants