Git Product home page Git Product logo

r0x0r / pywebview Goto Github PK

View Code? Open in Web Editor NEW
4.3K 63.0 515.0 30.8 MB

Build GUI for your Python program with JavaScript, HTML, and CSS

Home Page: https://pywebview.flowrl.com

License: BSD 3-Clause "New" or "Revised" License

Python 95.21% C# 1.94% JavaScript 0.02% CSS 0.01% HTML 0.07% PowerShell 0.46% Shell 0.12% Java 2.18%
python webkit gtk linux windows gui osx cocoa html javascript

pywebview's People

Contributors

adbenitez avatar alecharing avatar alexcovizzi avatar astraluma avatar demberto avatar dependabot[bot] avatar ecpost avatar firai avatar fizzadar avatar irtimir avatar javad94 avatar keredson avatar max-uho avatar melvinkcx avatar mi4code avatar monkeywithacupcake avatar odtian avatar p4bl0- avatar peter23 avatar r-muthu-saravanan avatar r0x0r avatar rotu avatar sardination avatar sbbosco avatar shivaprsd avatar simonrob avatar starnight avatar tshemeng avatar xav1erw avatar zvibazak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pywebview's Issues

py32_gen import fails on python 3

I'm using Windown 7 64-bit. I installed pywebview with pip.
With Python 3.4.4:

python -c "import webview"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Anaconda3\lib\site-packages\webview\__init__.py", line 52, in <module>

    import webview.win32 as gui
  File "D:\Anaconda3\lib\site-packages\webview\win32.py", line 24, in <module>
    from win32_gen import *
ImportError: No module named 'win32_gen'

With Python 2.7.1 the import works.
It might be due to relative import issues?

Confirm on close

I'd like use this in my project, but one of my functional requirements is a confirm dialog on close.

Is this something that can be easily added?

Incompatibility With FormBorderStyle Enum & Python Keyword

So I'm testing out pywebview for possible inclusion to a project I'm working on. One of the appeals is its OS agnosticism. I'm trying out the http_server.py example module and I'm getting an exception thrown in winforms.py;Line 48.

C:\...>python webtest.py
Traceback (most recent call last):
  File "webtest.py", line 33, in <module>
    webview.create_window("My first HTML5 application", "http://127.0.0.1:23948")
  File "C:\Python35\lib\site-packages\webview\__init__.py", line 159, in create_window_initialize_imports()
  File "C:\Python35\lib\site-packages\webview\__init__.py", line 73, in _initialize_imports
    import webview.winforms as gui
  File "C:\Python35\lib\site-packages\webview\winforms.py", line 48
    self.FormBorderStyle = WinForms.FormBorderStyle.None
                                                                                      ^
SyntaxError: invalid syntax

What seems to be the problem is that the FormBorderStyle enumeration value of "None" is causing errors because that's also a python keyword. I ran a little test in IDLE to further investigate this.

>>> import clr
>>> import System.Windows.Forms as WinForms
>>> test = WinForms.FormBorderStyle
>>> test.None
SyntaxError: invalid syntax
>>> test.Fixed3D
2
>>> test.FixedDialog
3
>>> test.FixedSingle
1
>>> test.FixedToolWindow
5
>>> test.Sizable
4
>>> test.SizableToolWindow
6

Let me know if I'm missing something.

-Zach

SyntaxError Exception in Windows

I get a series of SyntaxError exceptions (see below for an example) when I create a window under Windows 10. It happens with any URL I load. Here is an example of the code:

import webview
webview.create_window("title", "http://google.com")

Sample from the stack trace:

ERROR:comtypes.comobject:Exception in DWebBrowserEvents2.DocumentComplete implementation:
Traceback (most recent call last):
File "c:\anaconda\envs\py35\lib\site-packages\comtypes_comobject.py", line 147, in call_without_this
result = mth(inargs)
File "c:\anaconda\envs\py35\lib\site-packages\comtypes\client_events.py", line 117, in error_printer
return func(args, **kw)
File "C:\Users\Admin\AppData\Roaming\Python\Python35\site-packages\webview\win32.py", line 273, in DocumentComplete
custom_doc = self.browser.Document.QueryInterface(ICustomDoc)
File "c:\anaconda\envs\py35\lib\site-packages\comtypes\client__init
.py", line 44, in wrap_outparam
return GetBestInterface(punk)
File "c:\anaconda\envs\py35\lib\site-packages\comtypes\client__init
_.py", line 110, in GetBestInterface
mod = GetModule(tlib)
File "c:\anaconda\envs\py35\lib\site-packages\comtypes\client_generate.py", line 112, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "c:\anaconda\envs\py35\lib\site-packages\comtypes\client_generate.py", line 188, in _CreateWrapper
mod = _my_import(fullname)
File "c:\anaconda\envs\py35\lib\site-packages\comtypes\client_generate.py", line 26, in _my_import
return import(fullname, globals(), locals(), ['DUMMY'])
File "c:\anaconda\envs\py35\lib\site-packages\comtypes\gen_3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0.py", line 32518
True = 1
^
SyntaxError: can't assign to keyword

OSX exception on file_dialog.py example.

2015-11-01 13:59:28.703 Python[840:19718] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x00007fff8ac1803c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8cb0676e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8ac17eed +[NSException raise:format:] + 205
3 Foundation 0x00007fff832405c0 _AssertAutolayoutOnMainThreadOnly + 83
4 Foundation 0x00007fff83240412 -[NSISEngine withBehaviors:performModifications:] + 31
5 AppKit 0x00007fff8d8fcd20 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 217
6 AppKit 0x00007fff8d8465cd -[NSWindow _setUpFirstResponderBeforeBecomingVisible] + 63
7 AppKit 0x00007fff8d9668a6 -[NSApplication _orderFrontModalWindow:relativeToWindow:] + 643
8 AppKit 0x00007fff8d966289 -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:] + 815
9 AppKit 0x00007fff8d965f47 -[NSApplication beginModalSessionForWindow:] + 37
10 AppKit 0x00007fff8d965e61 -[NSApplication runModalForWindow:] + 98
11 AppKit 0x00007fff8ddaca84 -[NSSavePanel runModal] + 323
12 _objc.so 0x000000010b5f37a7 ffi_call_unix64 + 79
13 ??? 0x0000000111491380 0x0 + 4584969088
)
2015-11-01 13:59:28.704 Python[840:19718] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x00007fff8ac1803c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8cb0676e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8ac17eed +[NSException raise:format:] + 205
3 Foundation 0x00007fff832405c0 _AssertAutolayoutOnMainThreadOnly + 83
4 Foundation 0x00007fff83246461 -[NSISEngine optimize] + 49
5 AppKit 0x00007fff8d8fcdf8 -[NSWindow(NSConstraintBasedLayout) _changeWindowFrameFromConstraintsIfNecessary] + 148
6 Foundation 0x00007fff8324048e -[NSISEngine withBehaviors:performModifications:] + 155
7 AppKit 0x00007fff8d8fcd20 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 217
8 AppKit 0x00007fff8d8465cd -[NSWindow _setUpFirstResponderBeforeBecomingVisible] + 63
9 AppKit 0x00007fff8d9668a6 -[NSApplication _orderFrontModalWindow:relativeToWindow:] + 643
10 AppKit 0x00007fff8d966289 -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:] + 815
11 AppKit 0x00007fff8d965f47 -[NSApplication beginModalSessionForWindow:] + 37
12 AppKit 0x00007fff8d965e61 -[NSApplication runModalForWindow:] + 98
13 AppKit 0x00007fff8ddaca84 -[NSSavePanel runModal] + 323
14 _objc.so 0x000000010b5f37a7 ffi_call_unix64 + 79
15 ??? 0x0000000111491380 0x0 + 4584969088
)
2015-11-01 13:59:28.705 Python[840:19718] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x00007fff8ac1803c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8cb0676e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8ac17eed +[NSException raise:format:] + 205
3 Foundation 0x00007fff832405c0 _AssertAutolayoutOnMainThreadOnly + 83
4 Foundation 0x00007fff83240412 -[NSISEngine withBehaviors:performModifications:] + 31
5 Foundation 0x00007fff832475ba -[NSISEngine fixupIntegralizationViolations] + 104
6 Foundation 0x00007fff832464e0 -[NSISEngine optimize] + 176
7 AppKit 0x00007fff8d8fcdf8 -[NSWindow(NSConstraintBasedLayout) _changeWindowFrameFromConstraintsIfNecessary] + 148
8 Foundation 0x00007fff8324048e -[NSISEngine withBehaviors:performModifications:] + 155
9 AppKit 0x00007fff8d8fcd20 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 217
10 AppKit 0x00007fff8d8465cd -[NSWindow _setUpFirstResponderBeforeBecomingVisible] + 63
11 AppKit 0x00007fff8d9668a6 -[NSApplication _orderFrontModalWindow:relativeToWindow:] + 643
12 AppKit 0x00007fff8d966289 -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:] + 815
13 AppKit 0x00007fff8d965f47 -[NSApplication beginModalSessionForWindow:] + 37
14 AppKit 0x00007fff8d965e61 -[NSApplication runModalForWindow:] + 98
15 AppKit 0x00007fff8ddaca84 -[NSSavePanel runModal] + 323
16 _objc.so 0x000000010b5f37a7 ffi_call_unix64 + 79
17 ??? 0x0000000111491380 0x0 + 4584969088
)

Error: This module requires PyQt4 or PyQt5 to work under Linux.

I was getting an error that 'PyQt5 was not found' and also This module requires PyQt4 or PyQt5 to work under Linux. even though it was actually installed on my Linux Machine (Arch Linux), this is due to the fact that QtWebKitWidgets has been deprecated in Qt 5.5 and eventually removed in Qt 5.6 in favour of QtWebEngineWidgets, all this came from an ImportError that was raised when QtWebKitWidgets wasn't found in PyQt5. it's likely to affect Arch Linux / Fedora users or other users who run an updated version of Qt5 for some reason (Kde5 maybe)

I've already made a PR to address this
This commit fixed an issue when trying to import PyQt5 #47
#47

Installation Help on Apple OSX 10.9.5

This project looks very interesting and promising but I have no clue how to get it up and running despite a ton of wrangling/effort. The issue lies with finding the correct module/library called WebKit for python (I believe I need to install either Gnome/webkitgtk/pywebkitgtk or something to that nature)....

Here's where webview.py is calling that "WebKit" module in your code:

# Mac imports
if platform.system() == "Darwin":
    # Import PyObjC modules
    from Foundation import *
    from AppKit import *
    import WebKit
    logger.info("Using Cocoa")
    _create_window_func = "_create_window_mac"

And here's the error I'm encountering pops up(FYI):

image

Any help or direction would be great --- also Windows support would be awesome (I tend to build things that are multi-environment friendly)

Thanks,
-Doug Jr.

Application cannot be frozen with PyInstaller on Windows

The culprit is the win32com.shell import. See pyinstaller/pyinstaller#1322 for more details. There is currently no resolution for this problem on the PyInstaller end.

One workaround is to remove this import and the related code (see win32.py, lines 182-186). win32com.shell functionality is required by open folder dialog. So if you don't use it, this will do the trick.

pythonnet or not?

Since no matter what, you need pywin32 and comtypes, is there an appreciable difference to users between using pythonnet (and the .NET API) or not (and the Win32/COM API)?

toggle_fullscreen() functionality

Introduce a toggle_fullscreen() function that would toggle fullscreen mode on a currently active monitor. Currently the fullscreen mode on startup is activated on a primary monitor and there is no way to force it on another monitor.

"About" menu

It would be great to have an "About" menu in the new default application menu.
This could display the app icon, the application name and some copyright and license infos.
E.g. a link to pywebview including its license could be added to this menu.

onQuit like events?

Hi, THANKS for such module.

Is there any event like when a user close the window the event will trigger? I have a bottle server running so what i wanted to do is when the user close the app the server will be destroyed on closing the app.

Pywebview cutting out html/js features

Hi. I've been working on a production level project for a while now involving pywebview. The client and I recently noticed that one of the html files displayed is lacking certain features when displayed in pywebiew. The features are present when it's opened in any browser. I'm uploading screenshots and the html files in hope that it can be fixed. I tested this error by opening the html files with a python shell command copied from the quickstart, so it's not other code in my program.
htmlfiles.zip

screenshot 27
screenshot 26

svcVersion not in registry keys

Running Windows XP, python 3.3:

    Traceback (most recent call last):
      File "C:\Documents and Settings\user1\Desktop\pywebview-master\pywebview-master\examples\http_serv
    er.py", line 32, in <module>
        webview.create_window("My first HTML5 application", "http://127.0.0.1:23948")
      File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\main.py", line 72, in create_w
    indow
        gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscree
    n)
      File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\win32.py", line 213, in create
    _window
        set_ie_mode()
      File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\win32.py", line 265, in set_ie
    _mode
        mode = get_ie_mode()
      File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\win32.py", line 245, in get_ie
    _mode
        version, type = winreg.QueryValueEx(ie_key, "svcVersion")
    FileNotFoundError: [WinError 2] The system cannot find the file specified

Suggested fix to win32.py:

def get_ie_mode():
    """
    Get the installed version of IE
    :return:
    """
    ie_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'Software\Microsoft\Internet Explorer')
    try:
        version, type = winreg.QueryValueEx(ie_key, "svcVersion")
    except FileNotFoundError:
        version, type = winreg.QueryValueEx(ie_key, "Version")
    winreg.CloseKey(ie_key)

Underlying browser does not resize with window under windows

Hi,

When resize is set to True, the webview window can be resized, but the underlying browser instance does not resize with it. See the screenshot below:

screen shot 2015-10-25 at 11 55 12 am

It seems a pity I'm only getting in touch when something is going wrong, but pywebview is sensational!

with thanks

Add support for application icon on Windows

Application icon displayed in the taskbar / application window must be defined in application code. In contrast the icon displayed in Explorer is specified by freeze framework (eg. py2exe).

Scrolling stops when scrolling a big list.

I have created a div with overflow-y:auto; which creates a scroll in div, when extra elements are there in that div,

Problem is, the scroll stops in between when you scroll up or down.

I am on Mac Os x el capitan.

Between Awesome work, thanks

global name 'Gdk' is not defined

Hello, I'm having some beginner problems with this. Any help greatly appreciated.

I'm on ubuntu 14.04 LTS, using a python 2.7 virtualenv setup. I installed the module via pip install pywebview.

I'm running the following simple example:

import webview
webview.create_window('It works, Jim!', 'http://www.flowrl.com')

and getting the following exception:

(env1_v1)loknar@turninn:~/repo/webview-test$ python webview_test.py 
WARNING:webview.qt:PyQt4 is not found
WARNING:webview.qt:PyQt5 is not found
WARNING:webview:QT not found
WARNING:webview.gtk:PyGObject is not found
Traceback (most recent call last):
  File "/home/loknar/.virtualenvs/env1_v1/local/lib/python2.7/site-packages/webview/gtk.py", line 15, in <module>
    from gi.repository import Gtk as gtk
ImportError: No module named gi.repository
Traceback (most recent call last):
  File "webview_test.py", line 6, in <module>
    webview.create_window('It works, Jim!', 'http://www.flowrl.com')
  File "/home/loknar/.virtualenvs/env1_v1/local/lib/python2.7/site-packages/webview/__init__.py", line 94, in create_window
    gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscreen, min_size)
  File "/home/loknar/.virtualenvs/env1_v1/local/lib/python2.7/site-packages/webview/gtk.py", line 116, in create_window
    browser = BrowserView(title, url, width, height, resizable, fullscreen, min_size)
  File "/home/loknar/.virtualenvs/env1_v1/local/lib/python2.7/site-packages/webview/gtk.py", line 31, in __init__
    Gdk.threads_init()
NameError: global name 'Gdk' is not defined
(env1_v1)loknar@turninn:~/repo/webview-test$

Additional info:

(env1_v1)loknar@turninn:~$ sudo apt-get install python-qt4
[sudo] password for loknar:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-qt4 is already the newest version.
The following packages were automatically installed and are no longer required:
  account-plugin-windows-live libc-ares2 libupstart1 linux-headers-3.16.0-30
  linux-headers-3.16.0-30-generic linux-headers-3.16.0-40
  linux-headers-3.16.0-40-generic linux-headers-generic-lts-utopic
  linux-image-3.16.0-30-generic linux-image-3.16.0-40-generic
  linux-image-extra-3.16.0-30-generic linux-image-extra-3.16.0-40-generic
  linux-image-generic-lts-utopic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.

webview.load_url() segfaults on Linux

Using the gtkwebkit,

#!/usr/bin/env python
import webview
import threading

t = threading.Thread(target=webview.create_window, args=("Test", "about:blank"))
t.start()

webview.load_url("https://www.google.com/")

Produces:

/home/astronouth7303/.virtualenvs/smol/lib/python3.5/site-packages/webview/gtk.py:15: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk as gtk
/home/astronouth7303/.virtualenvs/smol/lib/python3.5/site-packages/webview/gtk.py:18: PyGIWarning: WebKit was imported without specifying a version first. Use gi.require_version('WebKit', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import WebKit as webkit
INFO:webview:Using GTK

Segmentation fault (core dumped)

Prints not Python 3 compatible

Your print statements (in the win32.py) are not compatible with python 3, in that they do not have brackets.

class EventSink(object):

    # some DWebBrowserEvents
    def OnVisible(self, this, *args):
        print("OnVisible", args)

    def BeforeNavigate(self, this, *args):
        print("BeforeNavigate", args)

    def NavigateComplete(self, this, *args):
        print("NavigateComplete", this, args)
        return

    def OnQuit(self, this, *args):
        print("OnQuit", args)



    # some DWebBrowserEvents2
    def BeforeNavigate2(self, this, *args):
        print("BeforeNavigate2", args)

    def NavigateComplete2(self, this, *args):
        print("NavigateComplete2", args)

    def WindowStateChanged(self, this, *args):
        print("WindowStateChanged", args)

Fullscreen window stuck in corner on Windows 10

When I create a window in full screen mode, it's stuck in the corner as pictured in the screenshot. I've racked my brains and the web, but nothing works. My attempted fixes include scaling my display res down to 1920*1080 in case it didn't support 4k, running the file in a wide variety of different ways, using different html files, and using gtk instead of qt. So far none have worked.
screenshot 73

FileNotFoundError is only for python 3.x

According to issue #5 ,in Windows XP, python 2.7

File "C:\Python27\Lib\site-packages\webview\win32.py", line 306, in get_ie_mode
    except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined

Solved by adding a line here:

    try:
        import _winreg as winreg  # Python 2
        FileNotFoundError = WindowsError # There is no FileNotFoundError in Python 2.x
    except ImportError:
        import winreg  # Python 3

FEATURE_BROWSER_EMULATION not in winreg.HKEY_CURRENT_USER

Running Windows 7, Python 2.7:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Fritz\Documents\webgui-demo\venv\lib\site-packages\webview\main.py", line 72, in create_window
    gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscreen)
  File "C:\Users\Fritz\Documents\webgui-demo\venv\lib\site-packages\webview\win32.py", line 185, in create_window
    set_ie_mode()
  File "C:\Users\Fritz\Documents\webgui-demo\venv\lib\site-packages\webview\win32.py", line 239, in set_ie_mode
    0, winreg.KEY_ALL_ACCESS)
WindowsError: [Error 2] The system cannot find the file specified

It seems that on my machine the FEATURE_BROWSER_EMULATION is in HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER. When I change the winreg.OpenKey(...) accordingly I get an [Error 5] (Access denied). :-(

error on Windows when trying example in readme

the error i'm getting is:

Traceback (most recent call last):
File "", line 254, in run_nodebug
File "", line 3, in
File "C:\Python27\lib\site-packages\webview\main.py", line 72, in create_window
gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscreen)
File "C:\Python27\lib\site-packages\webview\win32.py", line 233, in create_window
browser_view = BrowserView(title, url, width, height, resizable, fullscreen)
File "C:\Python27\lib\site-packages\webview\win32.py", line 157, in init
self.create_main_window()
File "C:\Python27\lib\site-packages\webview\win32.py", line 177, in create_main_window
None, None, BrowserView.wndclass.hInstance, None)
pywintypes.error: (1407, 'CreateWindowEx', 'Cannot find window class.')

could the error be related to amd64 version i'm using?

Getting issue regarding comtypes on Win7-64bit

I'm just testing this package out, and whilst it is working, I am getting some errors in the console output. The full console text is below.

127.0.0.1 - - [04/Aug/2016 12:20:04] "GET / HTTP/1.1" 200 204
# Generating comtypes.gen._3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0
Traceback (most recent call last):
  File "myvirtualenv\lib\site-packages\comtypes\client\_events.py", line 117, in error_printer
    return func(*args, **kw)
  File "myvirtualenv\lib\site-packages\webview\win32.py", line 273, in DocumentComplete
    custom_doc = self.browser.Document.QueryInterface(ICustomDoc)
  File "myvirtualenv\lib\site-packages\comtypes\client\__init__.py", line 44, in wrap_outparam
    return GetBestInterface(punk)
  File "myvirtualenv\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
    mod = GetModule(tlib)
  File "myvirtualenv\lib\site-packages\comtypes\client\_generate.py", line 112, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "myvirtualenv\lib\site-packages\comtypes\client\_generate.py", line 188, in _CreateWrapper
    mod = _my_import(fullname)
  File "myvirtualenv\lib\site-packages\comtypes\client\_generate.py", line 26, in _my_import
    return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "myvirtualenv\lib\site-packages\comtypes\gen\_3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0.py", line 90917
    True = 1
           ^
SyntaxError: can't assign to keyword
ERROR:comtypes._comobject:Exception in DWebBrowserEvents2.DocumentComplete implementation:
Traceback (most recent call last):
  File "myvirtualenv\lib\site-packages\comtypes\_comobject.py", line 147, in call_without_this
    result = mth(*inargs)
  File "myvirtualenv\lib\site-packages\comtypes\client\_events.py", line 117, in error_printer
    return func(*args, **kw)
  File "myvirtualenv\lib\site-packages\webview\win32.py", line 273, in DocumentComplete
    custom_doc = self.browser.Document.QueryInterface(ICustomDoc)
  File "myvirtualenv\lib\site-packages\comtypes\client\__init__.py", line 44, in wrap_outparam
    return GetBestInterface(punk)
  File "myvirtualenv\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
    mod = GetModule(tlib)
  File "myvirtualenv\lib\site-packages\comtypes\client\_generate.py", line 112, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "myvirtualenv\lib\site-packages\comtypes\client\_generate.py", line 188, in _CreateWrapper
    mod = _my_import(fullname)
  File "myvirtualenv\lib\site-packages\comtypes\client\_generate.py", line 26, in _my_import
    return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "myvirtualenv\lib\site-packages\comtypes\gen\_3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0.py", line 90917
    True = 1
           ^
SyntaxError: can't assign to keyword

Packaging with PyInstaller: Icon not found.

I am using PyInstaller to package my application as an executable.
It packages fine, and no special instructions are required for pywebview.
However, when executing the program, it fails to find the icon resource. (win32.py line 98).
I guess it should be possible to configure something on pyinstaller parameters, but it would be nice to just have an option to not load an icon for pywebview.
(As a workaround I am currently just commenting this line from win32.py: self.wndclass.hIcon = win32gui.LoadIcon(self.wndclass.hInstance, 1))

Not working in virtualenvwrapper

Hello!

When I run pywebview inside a virtualenv everthing seems to work fine. However, recently i started using virtualenvwrapper instead and suddenly I get this:

WARNING:webview.gtk:PyGObject is not found Traceback (most recent call last): File "/home/joakim/.virtualenvs/tradebuddy/lib/python3.5/site-packages/webview/gtk.py", line 15, in <module> from gi.repository import Gtk as gtk ImportError: No module named 'gi' INFO:webview:Using GTK Traceback (most recent call last): File "web-view-gui.py", line 6, in <module> webview.create_window("Simple browser", "http://localhost:3000", width=1200, height=800, resizable=True) File "/home/joakim/.virtualenvs/tradebuddy/lib/python3.5/site-packages/webview/__init__.py", line 160, in create_window gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscreen, min_size, _webview_ready) File "/home/joakim/.virtualenvs/tradebuddy/lib/python3.5/site-packages/webview/gtk.py", line 127, in create_window browser = BrowserView(title, url, width, height, resizable, fullscreen, min_size, webview_ready) File "/home/joakim/.virtualenvs/tradebuddy/lib/python3.5/site-packages/webview/gtk.py", line 34, in __init__ Gdk.threads_init() NameError: name 'Gdk' is not defined
I can not for my life understand why there whould be a difference. But there is...
I'm on Arch using Python 3.5.2, python-gopbject 3.22.0-1 and pywebview 1.2.2

True = 1

Hi, I'm running the newest version of python (3.5.1 i think) and the example is giving me stack traces.

import webview

webview.create_window("It works, Jim!", "http://www.flowrl.com")

prints lots of these to stderr (the program does keep running):

SyntaxError: can't assign to keyword
# Generating comtypes.gen._3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_events.py", line 117, in error_printer
    return func(*args, **kw)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\webview\win32.py", line 273, in DocumentComplete
    custom_doc = self.browser.Document.QueryInterface(ICustomDoc)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\__init__.py", line 44, in wrap_outparam
    return GetBestInterface(punk)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
    mod = GetModule(tlib)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_generate.py", line 112, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_generate.py", line 188, in _CreateWrapper
    mod = _my_import(fullname)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_generate.py", line 26, in _my_import
    return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\gen\_3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0.py", line 88274
    True = 1
           ^
SyntaxError: can't assign to keyword
ERROR:comtypes._comobject:Exception in DWebBrowserEvents2.DocumentComplete implementation:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\_comobject.py", line 147, in call_without_this
    result = mth(*inargs)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_events.py", line 117, in error_printer
    return func(*args, **kw)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\webview\win32.py", line 273, in DocumentComplete
    custom_doc = self.browser.Document.QueryInterface(ICustomDoc)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\__init__.py", line 44, in wrap_outparam
    return GetBestInterface(punk)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
    mod = GetModule(tlib)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_generate.py", line 112, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_generate.py", line 188, in _CreateWrapper
    mod = _my_import(fullname)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\client\_generate.py", line 26, in _my_import
    return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\comtypes\gen\_3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0.py", line 88274
    True = 1
           ^
SyntaxError: can't assign to keyword

And they just keep coming after each
# Generating comtypes.gen._3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0

Support for multiple windows?

This feature will probably change the API significantly, but I wanted to at least document the need.

Essentially my idea would be that the webview.create_window() function returns a window handle or maybe even a BrowserView object that can be manipulated directly. That way you could instantiate multiple windows and destroy them individually.

Perhaps the app can quit when the last window is destroyed, or maybe there could be a 'master' window instance that can control all the other ones.

I'm kind of spit-balling but hopefully you get the idea. Could pywebview support multiple windows? Can you think of some other way to do it that doesn't involve a major API change?

Disable right-click context menus

Right clicking on the browser container generates a context menu on every platform. They must be disabled in order to hide implementation details and prevent unwanted actions such as page reload. Any input on how this could be achieved on any platform is appreciated.

webview crashes when showing an image

I am testing pywebview in order to make a simple digital signage application.

Webview shows most of the urls ok (even youtube fullscreen videos!), but when I give it a jpg or png url (local or http), a Segmentation Fault error comes out.

I am using ubuntu 14.04.

lacking Python 3.5 support on OS X

Seems pywebview requires PyObjC, and when you import webview into your Python 3.5 code with pyobjc version 3.0.4, you run into the error message "Symbol not found: _PyObject_REPR".

You need to upgrade to pyobjc version 3.0.5 or later to fix this.

At the time of this writing, 3.0.5 has not officially been released, yet, so you can either wait for the official release or install a pyobjc beta like:

pip3 install -U https://github.com/GreatFruitOmsk/pyobjc-core/releases/download/v3.0.5.dev0/pyobjc-core-3.0.5.tar.gz

Take care, that's a third party install location.

Installation via pip fails on Linux under Python 3

The version of PyGObject on PyPI is extremely old (last upload was 2011) and fails to install under Python 3 due to a syntax error. This makes pywebview unusable in a virtualenv (unless using the --system-site-packages option) or when using something like Anaconda rather than the system Python. Possible solutions:

  • Switch to Qt as the default on Linux since PyQt4/5 are installable via pip (possibly just for Python 3)
  • Don't explicitly require pygobject in setup.py but instead add installation instructions that note needing to use the system package for Linux

No application menu for Mac apps

A common pattern for Mac applications is to have an application menu available to perform functions like quitting the application or viewing the 'About...' menu. I've attached a screenshot of the application menu from a sample application packaged with py2app to show what it normally looks like.

screenshot 2016-06-06 16 59 13

In apps that are created with pywebview and packaged with py2app the application menu isn't accessible. The app name appears in its usual place but clicking it does not produce a menu. Is there a way to enable this functionality?

Non-integer screenwidth

Running windows XP, Python 3.3, attempting to create a window returned the error:

        Traceback (most recent call last):
          File "C:\Documents and Settings\user1\Desktop\pywebview-master\pywebview-master\examples\http_serv
        er.py", line 32, in <module>
            webview.create_window("My first HTML5 application", "http://127.0.0.1:23948")
          File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\main.py", line 72, in create_w
        indow
            gui.create_window(_make_unicode(title), _transform_url(url), width, height, resizable, fullscree
        n)
          File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\win32.py", line 214, in create
        _window
            browser_view = BrowserView(title, url, width, height, resizable, fullscreen)
          File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\win32.py", line 121, in __init
        __
            self._create_main_window()
          File "C:\Python33\lib\site-packages\pywebview-0.5-py3.3.egg\webview\win32.py", line 160, in _creat
        e_main_window
            None, None, self.wndclass.hInstance, None)
        TypeError: integer argument expected, got float

Suggested fix to win32.py:

        def _create_main_window(self):
            # Set window style
            style = win32con.WS_VISIBLE
            if self.resizable:
                style = style | win32con.WS_OVERLAPPEDWINDOW
            else:
                style = style | (win32con.WS_OVERLAPPEDWINDOW ^ win32con.WS_THICKFRAME)

            #  Center window on the screen
            screen_x = _user32.GetSystemMetrics(win32con.SM_CXSCREEN)
            screen_y = _user32.GetSystemMetrics(win32con.SM_CYSCREEN)
            x = int((screen_x - self.width) / 2)
            y = int((screen_y - self.height) / 2)

Extended Screens

I have dual screens on my computer and i would like to have pywebview to run fullscreen on the secondary screen instead of the primary screen. It would be nice if there's option to run full screen on my secondary screen on the right, etc.
e.g. webview.create_window("Full-screen browser", "http://www.flowrl.com", left=1024, top=0, fullscreen=True)

mac version fullscreen

I tried to create a window in fullscreen but it doesn't work for me, it creates a 800x600 window

AttributeError: 'BrowserView' object has no attribute 'browser'

Hi,

When I send a request from a controller in the web.py webserver (running in its of thread) I get the following error:

INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): web.site.example
ERROR:comtypes._comobject:Exception in DWebBrowserEvents2.DocumentComplete implementation:
Traceback (most recent call last):
File "comtypes_comobject.pyo", line 147, in call_without_this
File "comtypes\client_events.pyo", line 117, in error_printer
File "webview\win32.pyo", line 273, in DocumentComplete
AttributeError: 'BrowserView' object has no attribute 'browser'

Do you have any idea why this error is thrown on Windows 2003 / 2012? When I run the App in Pycharm in combination with Linux everything works like a charm...

This is the code that I'm using for the request:

import web
import json
import requests
from requests.auth import HTTPBasicAuth


class ApiSettings:

    def GET(self):
        practice_number = web.input().practice_number
        data = {
            'status': 404,
            'message': '',
            'data': {}
        }

        if len(practice_number) == 4 and practice_number.isdigit():

            r = requests.get('https://web.site.example/something'.format(practice_number),
                             auth=HTTPBasicAuth('user', 'password'))

            if r.status_code != 200:
                data['status'] = r.status_code
                data['message'] = 'Can\'t retrieve data'
            else:
                 response = r.json()

                 data['status'] = response['status']
                 data['message'] = response['message']

        web.header('Content-Type', 'application/json')
        return json.dumps(data)


Thanks for looking at this :)

Add support for EdgeHTML in Windows 10

Win32 API in Windows 10 has only support for MSHTML missing out new features of EdgeHTML. EdgeHTML can apparently be embedded only using .NET, unless it provides a COM interface. If the .NET route is chosen, then Python for .NET seems to be a right tool for the job.

SyntaxError in comtypes package with Python 3 / Win32

The generated code in the current version of comtypes does not provide support for Python 3. As a result the following error is thrown, when comtypes code is invoked on Windows

True = 1
^
SyntaxError: can't assign to keyword

The fix has been made to the comtypes master branch, but there is no release yet. As a workaround you have to monkey-patch the comtypes code located in PYTHON_FOLDER\lib\site-packages\comtypes\tools\codegenerator.py with the following diff.

pywebview doesn't always size it's content correctly at startup under windows

hi,

when i first launch my application, the content isn't sized correctly to begin with. about 20 pixels are outside the view port to the right and to the bottom. if you look at the following screenshot, you can see a line of pixels at the right belonging to the scrollbar which is mostly outside the view port.

screen shot 2015-10-26 at 12 21 36 pm

if i resize the window just slightly, by a single pixel, it resizes the content to the viewport correctly. see this next screenshot.

screen shot 2015-10-26 at 12 21 47 pm

i appreciate this may be a bug in upstream, i.e. in the activex control container (or whatever you use), but perhaps this could be worked around by sending a resize message to the control after it is made visible? just a thought. (i always get annoyed when people who have no idea how my software works, make suggestions for how i can fix things; so i probably shouldn't make these suggestions :P )

once again, thank you for all your work on pywebview!

jonathon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.