r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.74k stars 554 forks source link

GTK used even when not installed #84

Closed AstraLuma closed 7 years ago

AstraLuma commented 7 years ago
WARNING:webview.gtk:PyGObject is not found
Traceback (most recent call last):
  File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/gtk.py", line 16, in <module>
    import gi
ModuleNotFoundError: No module named 'gi'
INFO:webview:Using GTK
Exception in thread webview:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/astronouth7303/code/smol/smol/pyq/webview.py", line 50, in run
    webview.create_window(**self._args)
  File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/__init__.py", line 175, in create_window
    gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscreen, min_size, _webview_ready)
  File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/gtk.py", line 155, in create_window
    browser = BrowserView(title, url, width, height, resizable, fullscreen, min_size, webview_ready)
  File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/gtk.py", line 41, in __init__
    Gdk.threads_init()
NameError: name 'Gdk' is not defined

I think it's because the ImportError isn't reraised.

r0x0r commented 7 years ago

Does this occur when you attempt to use qt?

On Feb 23, 2017 2:31 AM, "Jamie Bliss" notifications@github.com wrote:

WARNING:webview.gtk:PyGObject is not found Traceback (most recent call last): File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/gtk.py", line 16, in import gi ModuleNotFoundError: No module named 'gi' INFO:webview:Using GTK Exception in thread webview: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/home/astronouth7303/code/smol/smol/pyq/webview.py", line 50, in run webview.create_window(**self._args) File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/init.py", line 175, in create_window gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscreen, min_size, _webview_ready) File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/gtk.py", line 155, in create_window browser = BrowserView(title, url, width, height, resizable, fullscreen, min_size, webview_ready) File "/home/astronouth7303/.virtualenvs/smol/lib/python3.6/site-packages/webview/gtk.py", line 41, in init Gdk.threads_init() NameError: name 'Gdk' is not defined

I think it's because the ImportError isn't reraised.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/r0x0r/pywebview/issues/84, or mute the thread https://github.com/notifications/unsubscribe-auth/ABelWfIbQkCNbadMuYxBfq3CwUQ4Q5w-ks5rfNNjgaJpZM4MJYey .

maroc81 commented 7 years ago

I'm seeing the same problem. In gtk.py if the import fails, the exception is not rereaised so the rest of gtk.py is executed and the fails when it gets to Gdk since it's undefined. In order for the init.py code to fall back to trying qt for Linux platforms you need to rereaise the import exception in gtk.py.

r0x0r commented 7 years ago

I have removed exception handling in the GTK module. The problem should be gone now. The fix is in the master branch.