moses-palmer / pystray

GNU General Public License v3.0
482 stars 59 forks source link

`run_detached` errors unconditionally in non-OSX platforms #102

Closed Techcable closed 2 years ago

Techcable commented 3 years ago

I am using Linux in the context of a GTK webapp using pywebview.

  <calling context omitted for privacy>
  File "/home/nicholas/.local/lib/python3.9/site-packages/pystray/_base.py", line 384, in <lambda>
    threading.Thread(target=lambda: self.run(setup)).start()

I believe the error is here: https://github.com/moses-palmer/pystray/blob/21d0e5d98b2e98a9a8641a82cd05eaf4113c048d/lib/pystray/_base.py#L384

It should be present on all non-OSX platforms, regardless of whether or not setup is set or not :frowning:

Is some sort of better integration with Linux needed?

moses-palmer commented 3 years ago

Thank you for your report!

This is a very clear bug, and I will correct is as soon as possible.

Techcable commented 3 years ago

Hi! I've managed to work around this issue by spawning a subprocess to deal with the webview and have the parent process handle the icon.

Although this is kind of hacky, this fixes most of my issues :wink:

mmsbr commented 3 years ago

I'm using windows and I'm having the same problem: I tried to edit _base.py removing the "setup" variable:

threading.Thread(target=lambda: self.run()).start()

It worked well but now I can't stop the program calling stop() Can anyone point me how can I manage to stop the thread properly?

eyrinck commented 2 years ago

Hi, I'm very new to python, so please be patient if I'm wrong. Tried the "run_detached" method on windows 10 and reached an error in the same line. I noticed in your source code that "_run_detached" gets no argument "setup" . After correcting it everything works fine for me. Hope I'm right and this is helpfull: changed: def _run_detached(self): to def _run_detached(self,setup): in "run_detached" I changed self._run_detached() to self._run_detached(setup)

eyrinck commented 2 years ago

I have to correct myself, the "stop" method hangs now infinite when trying to exit the program.

moses-palmer commented 2 years ago

@eyrinck, @mmsbr and @Techcable, there is a new release, pystray 0.19.0, which incorporates the fix previously only available in the development version.