pyqt5

embed a aiohttp server in a PyQt application

戏子无情 提交于 2021-02-05 08:08:47
问题 I am going to embed a aiohttp server in a PyQt application, but when I run the code below , the Qt window couldn't show, I know it was caused by web.run_app(app) , I've tried to move it into a thread , but then I got RuntimeError: There is no current event loop in thread 'Dummy-1' , so what should I do ? I've found asyncqt which might help ,but I don't know how to use it to deal with a aiohttp server. from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * from

Plotting with pyqtgraph without displaying

有些话、适合烂在心里 提交于 2021-02-05 08:08:30
问题 I am trying to move from matplotlib to plotting with pyqtgraph because of its touted capabilities to render and save images faster. In my attempts to do this on a cluster with multiprocessors, I run into the following trouble: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-user' qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display. How do I obviate displaying a plot, and save it directly to file? Here's my attempt at the code:

KeyPressEvent without Focus

自古美人都是妖i 提交于 2021-02-05 07:58:06
问题 I am programming a simple GUI, that will open a opencv window at a specific point. This window has some very basic keyEvents to control it. I want to advance this with a few functions. Since my QtGui is my Controller, I thought doing it with the KeyPressedEvent is a good way. My Problem is, that I cannot fire the KeyEvent, if I am active on the opencv window. So How do I fire the KeyEvent, if my Gui is out of Focus? Do I really need to use GrabKeyboard? The following code reproduces my

Using QComboBox in QTableView properly - issues with data being set and clearing QComboBoxes

家住魔仙堡 提交于 2021-02-05 07:39:57
问题 In my application im using a QTableView, QStandardItemModel and a QSortFilterProxyModel in between for filtering. The content is updated via a method for columns 1 & 2, and I want there to be a 3rd column for user to select options. I would prefer to use a QComboBox. I've got everything pretty much working, except that when I select the item from the QComboBox in any of the cells in column 3, it doesn't populate. Does it have something to do with my setModelData() method? I also have a clear

Decorator adds an unexpected argument

佐手、 提交于 2021-02-05 07:29:24
问题 I wanted to use a decorator to handle exceptions in my PyQt5 application: def handle_exceptions(func): def func_wrapper(*args, **kwargs): try: print(args) return func(*args, **kwargs) except Exception as e: print(e) return None return func_wrapper class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) loadUi("main_window.ui",self) self.connect_signals() def connect_signals(self): self.menu_action.triggered.connect(self.fun) @handle_exceptions def fun(self): print("hello

connect a function when menu title is clicked

纵然是瞬间 提交于 2021-02-05 06:58:25
问题 I am trying to find open ports and add them to my menu. Right now, what I succeed having an action to my menu (like, "find ports"), and only if it's clicked - it will connect to my function that gets all free ports. Unfortunately, that's not what I am looking for. I want to click on the menu title , and get all port in my menu. Below is the code I have: This is the GUI part: from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow

IDLE unable to find PyQt5 installation

不想你离开。 提交于 2021-02-05 06:52:09
问题 I'm trying to install and use PyQt5 on my Windows 10 computer. Actually, it's already installed but IDLE does not recognize the package. I tried to import PyQt5 after I installed it but I got an import error. Then I tried something else: pip install pyqt5 Here, I got a syntax error. Does anybody have an idea what's the problem? Thanks in advance. 回答1: Installing Python 3.6.6 & PyQt5 on Windows (10) Python3.6.6: Download & Install Python 3.6.6 https://www.python.org/downloads/windows/ PyQt5:

IDLE unable to find PyQt5 installation

巧了我就是萌 提交于 2021-02-05 06:52:01
问题 I'm trying to install and use PyQt5 on my Windows 10 computer. Actually, it's already installed but IDLE does not recognize the package. I tried to import PyQt5 after I installed it but I got an import error. Then I tried something else: pip install pyqt5 Here, I got a syntax error. Does anybody have an idea what's the problem? Thanks in advance. 回答1: Installing Python 3.6.6 & PyQt5 on Windows (10) Python3.6.6: Download & Install Python 3.6.6 https://www.python.org/downloads/windows/ PyQt5:

Use webengine video and audio codecs

穿精又带淫゛_ 提交于 2021-02-05 06:46:33
问题 For my PyQt5 project, I am using the QWebEngineView , but certain videos, such as .mp4 videos won't play. Can I install the codecs with pip , or pass a certain argument through QApplication() or something similar in order to fix this problem? I installed PyQt5 through pip , so I don't have the C:\Qt\... files, only the PyQt5 , pyqt5_tools folders in Appdata\Local\Programs\Python\Python37\Lib\site-packages . I am using Python 3.7.2 , and PyQt5.11 回答1: The pyqtwebengine provided by pypi does

Create a QTableWidgetItem with flags()

拈花ヽ惹草 提交于 2021-02-05 05:58:37
问题 I dont understand the Qt5 Documentation in the TableWidgetItem-Chapter. I cant get the right parameters to set my freshly created TableCell as editable. I've got this piece of code for i, item in enumerate(event_desc, start=0): print(i, item) key = QTableWidgetItem(list(event_desc)[i]) value = QTableWidgetItem(event_desc[item]) value.setFlags( * what's to insert here? * ) tw.insertRow(i) tw.setItem(i, 0, key) tw.setItem(i, 1, value) The first param should be *self, the 2nd one is named 'Union