qwebengineview

PyQt5/PySide2 AdBlock

∥☆過路亽.° 提交于 2021-02-16 15:04:27
问题 I am trying to create a floating browser for youtube and other media. I found some old examples of adblock like for PyQt4/PySide but now they are deprecated and I can't translate them to PySide2 QWebEngineView. Any ideas of how insert the adblock inside a QWebEngineView? Older version link How would you adblock using Python? 回答1: To filter urls, a QWebEngineUrlRequestInterceptor must be implemented, and if you want to block the url you must call the block (True) function to the

PyQt QtWebChannel: calling Python function from JavaScript

强颜欢笑 提交于 2021-02-04 04:49:55
问题 I am trying, using Qt classes QWebEngineView , and QWebChannel to make a simple connection between HTML page and Python script. The goal is simply to execute foo() when the header <h2> is clicked. import sys from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QApplication from PyQt5.QtWebChannel import QWebChannel from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage html = ''' <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script src="qrc:///qtwebchannel

CSS doesn't work in QWebEngineView.setHtml()

我的未来我决定 提交于 2021-01-28 08:20:22
问题 I have a string obtained from rendering a Jinja template. In the template I have the absolute path to the css file. For example: <link rel='stylesheet' href="C:\Users\User\project\reports\template\css"> But, when I set the html in QWebEngineView only appear the plain HTML, without CSS. How can I make to detect the css reference? This is my code class WidgetEdificioCirsoc(QtWidgets.QWidget): def __init__(self): super().__init__() self._tab_edificio = widgets.TabEdificio() self._webview =

How to embed basic HTML page using Qt?

╄→尐↘猪︶ㄣ 提交于 2021-01-28 07:16:25
问题 I am using PySide2.QtWebEngineWidgets.QWebEngineView() to setHtml on it to show a basic page like below. This html file works fine in a browser because it has all the files in the same folder relative to the html file. Once I setHtml to the below file, I get this exception: Qt Error: Uncaught ReferenceError: require is not defined Is this related to Qt not finding the relative files unlike a regular browser? Or is there something else I should be doing? Or is QWebEngineView not advanced

Use QWebEngineView to Display Something Larger Than 2MB?

时光总嘲笑我的痴心妄想 提交于 2021-01-28 06:51:40
问题 I'm trying to display some Plot.ly or Plot.ly Dash plots ( I haven't settled on using one or the other, so I'm experimenting with both right now) in a PyQt5 GUI using QWebEngineView. This doesn't work for any plots larger than 2MB due to some Chromium-level hardcoded restriction. I found one similar question that is pretty much identical in terms of our needs. It looks like the OP actually found an answer, but unfortunately for me, they didn't post an example of working code or explain what

how to suppress console output from QWebEngineView errors?

孤者浪人 提交于 2021-01-28 06:08:43
问题 I get the following error if I create a QWebEngineView instance from Python instances in different working directories: [2452:9872:1108/052617.050:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5) [2452:9872:1108/052617.050:ERROR:cache_util.cc(135)] Unable to move cache folder C:\Users\Adam\AppData\Local\python\QtWebEngine\Default\GPUCache to C:\Users\Adam\AppData\Local\python\QtWebEngine\Default\old_GPUCache_000 [2452:9872:1108/052617.051:ERROR:disk_cache.cc(184)

QWebEngineUrlRequestInterceptor not working

荒凉一梦 提交于 2021-01-28 06:07:14
问题 Im migrating an application from PyQt4 to PyQt5. Im trying to override the request interceptor but this doesn't work for some strange reason, this is not getting picked up. I am using PyQt==5.10.0 class WebEngineUrlRequestInterceptor(QWebEngineUrlRequestInterceptor): def __init__(self, parent=None): super().__init__(parent) def interceptRequest(self, info): # info.setHttpHeader("X-Frame-Options", "ALLOWALL") print("test") print(info.requestUrl()) class MyWebEnginePage(QWebEnginePage): #

How to download csv file with QWebEngineView and QUrl

廉价感情. 提交于 2021-01-24 09:11:13
问题 I'm building a program which uses QWebEngineView and QUrl to display a website in my PyQt5 app (running on Windows 10). However, I now want to be able to download a CSV file from the same website, but being a noob I can't seem to figure out how. I'm familiar with using requests , urllib.request , urllib3 , etc. for downloading files, but for this, I specifically want to do it with the QWebEngineView, as the user will have authenticated the request previously in the pyqt5 window. The code to

How to print from QWebEngineView

荒凉一梦 提交于 2020-11-29 17:59:10
问题 I am trying to print a report from within my application, which involves both text and tables. Since QTextDocument won't be sufficient, I've decided to go with QWebEngineView and more sophisticated HTML/CSS which is not supported by the Qt rich text engine. I am able to create a PDF from the view, however I am having some general misconceptions, because at times its crashing, and also printing instead of PDF creation crashes. Here is my attempts: Approach 1: PDF creation This is the only

How to print from QWebEngineView

…衆ロ難τιáo~ 提交于 2020-11-29 17:56:54
问题 I am trying to print a report from within my application, which involves both text and tables. Since QTextDocument won't be sufficient, I've decided to go with QWebEngineView and more sophisticated HTML/CSS which is not supported by the Qt rich text engine. I am able to create a PDF from the view, however I am having some general misconceptions, because at times its crashing, and also printing instead of PDF creation crashes. Here is my attempts: Approach 1: PDF creation This is the only