Open The-Compiler opened 9 years ago
I spent some time finding out how to create a wrapper widget for QWebView
so it's completely decoupled - this is what works:
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QWidget, QLayout
from PyQt5.QtWebKitWidgets import QWebView
class WrapperLayout(QLayout):
def __init__(self, widget, parent=None):
super().__init__(parent)
self._widget = widget
def addItem(self, w):
assert False
def sizeHint(self):
return self._widget.sizeHint()
def itemAt(self, i):
assert False
def takeAt(self, i):
assert False
def setGeometry(self, r):
self._widget.setGeometry(r)
class Wrapper(QWidget):
def __init__(self, widget, parent=None):
super().__init__(parent)
self._layout = WrapperLayout(widget, self)
self._widget = widget
widget.setParent(self)
app = QApplication([])
wv = QWebView()
w = Wrapper(wv)
w.show()
w._widget.load(QUrl('http://cmpl.cc/'))
app.exec_()
Now the next question is what the API of this will look like, and what functionality the rest of the code needs.
Use cases I can think of: configuration/settings downloads (eventually) plugins view source (most other browsers have this, not sure it'd be a requirement though) developer tools informational (qute:version, etc) bookmarks release notes?
Thanks for the useful list!
For display-only things (qute:version
, release notes) I guess a webpage is preferable/easier.
:view-source
already exists and uses pygments to generate HTML, so that should be fine as well.
https://github.com/dhamaniasad/HeadlessBrowsers has some inspiration for APIs probably
Just noticed there wasn't an open issue for this yet.
There should probably some
Tab
class which is the class of all tabs in theTabbedBrowser
.Then there could be a
WebViewTab
or so which is the glue between aQWebView
and that tab "protocol" (in the Python sense of protocol), and there could also be some kind ofWidgetTab
orScrollAreaTab
or so.This will also be useful for #666, then there can be a
WebEngineViewTab
.qute:settings
and others should then probably migrate to that instead of using a web page (cc @iggy)