Closed mherrmann closed 7 years ago
Looks like gtk init failed (you can check the return of Gtk.init_check(None)
). no idea why.
I'd try to get things working with pygobject instead to rule out any missing pgi features.
Wow, that was a quick response. Thanks!
I've been having trouble getting pygobject installed in my virtualenv. Why would you recommend pygobject over pgi in this case?
try virtualenv --system-site-packages venv
Why would you recommend pygobject over pgi in this case?
Because pgi is currently so far away from feature complete that you can't run any reasonable sized/useful application with it.
The above code would be all I need so I was hoping that if it works from the shell then I may also be able to use it when my app is frozen. But I'll follow your advice. Thanks again!
Oh ok. just wanted to mention that I've only seen the above error when DISPLAY was missing, as you suspected. Not sure how "freezing" could affect that..
One difference I could see is that PyInstaller doesn't seem to ship dependencies as .py files but somehow encodes them inside a binary. It must then use some import hook to load them. I saw that pgi also uses import hooks. Could it be that the two clash somehow?
Yeah, that might be a problem and prevent python overrides from loading (this isn't tested at least).Try calling Gtk.init(sys.argv)
right after import.
You're a genius. Calling Gtk.init(sys.argv)
right after import fixes the problem!
I've opened #39 for this. Thanks.
Firstly, thanks for sharing this library. The concept is very elegant and useful.
I want to look up the icon for a directory (
/home/michael
in the code below):This works fine when I do it in my Python shell. However, when I freeze the above code with PyInstaller, I get:
The main problem seems to be the failing assertion
GDK_IS_SCREEN
. Googling for this assertion, I found that it may be related to the environment variablesDISPLAY
andXDG_CURRENT_DESKTOP
. Unfortunately, that doesn't seem to be it as they are both set correctly (to:0
andUnity
, respectively).Do you happen to know what else could cause the assertion
GDK_IS_SCREEN
to fail, in a frozen app?