pyqt5

How to add a tab to QTabWidget using the button on the form?

雨燕双飞 提交于 2021-01-28 08:22:18
问题 I decided to write a visual form for my script. The idea is to have a button that will add new tabs to QTabWidget. It does not work and I can not find a good example. I use PyQt5. Here's a piece of what I've tried: import sys from PyQt5.QtGui import QIcon from PyQt5 import QtCore, QtWidgets class mainForm(QtWidgets.QWidget): def __init__(self): super().__init__() self.runUi() def runUi(self): self.resize(250, 150) self.move(300, 300) self.setWindowTitle('Let\'s Rock!') self.setWindowIcon

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 =

Moving the cursor in a PyQt5 text edit doesn't work

喜夏-厌秋 提交于 2021-01-28 07:31:41
问题 I'm contributing to Frescboaldi, a PyQt5 application and experience problems interacting with the core text edit component. It seems whatever I try I can't get either of setPosition or movePosition to work. The code cursor.insertText("Hello") cursor.setPosition(cursor.position() - 5) properly inserts the text Hello in the document but leaves the cursor at the end of the inserted text (instead of moving it to the left by 5 characters). The first line proves that cursor, textedit and document

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

PyQt5 : QMediaPlayer can't replay audio from QBuffer

别等时光非礼了梦想. 提交于 2021-01-28 06:40:35
问题 I have a QBuffer in RAM with a temporary wav file, and I want to let the user listen it from any point as many times as (s)he want. But, it only allows playing it once, and doesn't allow replaying it. If I play the audio from a file ( QUrl.fromLocalFile ), it can replay it. What's the difference? How to fix it? 1) To play the wav file from RAM I use the following code: data = b"" with open(fname, "rb") as file: data = file.read() buf = QBuffer() buf.setData(data) #For debugging. Real buffer

Change editability for individual cells of QTableWidget

本秂侑毒 提交于 2021-01-28 06:30:22
问题 I use a QTableWidget as an I/O feature for the user but I want to make it more user friendly and intuitive by disabling the editability of cells which are only for data output. I can uncheck "Editable" under flags for each individual cell in Qt Designer but as soon as I change the value of a cell with self.table_item.setItem(row, column, QTableWidgetItem(str(value))) the cells is editable again. This question/answer suggest using self.table_item.setEditTriggers(QtWidgets.QTableWidget

ProgressBar resume from where it stopped

纵然是瞬间 提交于 2021-01-28 06:20:21
问题 I have created a desktop application by PYQT5 and python 3.7 to download a video by clicking the download button and save it locally in the PC. The code will fetch the video link from (lineEdit.text()) which is labeled "URL" and save it in the local directory in (lineEdit_2.text()) which is labeled "SAVE AS" . If the download stops for any reason, it will be resumed again by press the start download button. In addition, the ProgressBar start from 1% until 100% along with downloading the video

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): #

Button for duplicating tabs in a QTabWidget

戏子无情 提交于 2021-01-28 05:09:07
问题 I have a program that uses an input tab with multiple entry boxes for a user to fill out, and when those entry boxes are filled in, I hit run and another program will run the data entered. I'd like for my program to have a tab button with a plus sign that will duplicate the tabs dynamically so that I can run multiple instances. I'd like for each tab to use the same name, but have a variant at the end - e.g. "EntryBox0", "EntryBox1", "EntryBox2". Is there an easy way to do this, while keeping