pyqt

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

PyQt program connection between singal and function is not working

♀尐吖头ヾ 提交于 2021-02-05 06:42:04
问题 In this very simple PyQt based Python program start button does not work, it seems that there is no connection between the start button and _calculateResult method. I think something in _connectSignals() method is wrong, but I cannot find it. Do you have any idea about it? Thanks. import sys from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QLineEdit, QPushButton, QHBoxLayout class TimerUi(QMainWindow): def __init__(self): super().__init__() self

multi inherit from QObject and QRunnable error

ぐ巨炮叔叔 提交于 2021-02-05 06:10:35
问题 I'm using pyqt4. I have a class multi inherited from QObject and QRunnable like this: class DownloadTask(QObject, QRunnable): def __init__(self): QObject.__init__(self) QRunnable.__init__(self) self.setAutoDelete(False) When an instance of DownloadTask is initializing, the last line throws exception: TypeError: could not convert 'DownloadTask' to 'QRunnable' But I think it is correct in grammer, QRunnable has the method setAutoDelete. Why can't it convert to QRunnable? Update: I intend to use

multi inherit from QObject and QRunnable error

久未见 提交于 2021-02-05 06:06:11
问题 I'm using pyqt4. I have a class multi inherited from QObject and QRunnable like this: class DownloadTask(QObject, QRunnable): def __init__(self): QObject.__init__(self) QRunnable.__init__(self) self.setAutoDelete(False) When an instance of DownloadTask is initializing, the last line throws exception: TypeError: could not convert 'DownloadTask' to 'QRunnable' But I think it is correct in grammer, QRunnable has the method setAutoDelete. Why can't it convert to QRunnable? Update: I intend to use

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

Pyinstaller: Import Error: DLL load failed: The specified module could not be found

霸气de小男生 提交于 2021-02-05 05:56:07
问题 I'm trying create an executable from my code that uses PyQt5. I'm using Python 3.5.3 -64 bits, developing in Windows 10, and used pip to install pyinstaller 3.2.1. I run pyinstaller as such: pyinstaller.exe --onefile --windowed main.py I get an Import Error: File "C:\Python35\Scripts\pyinstaller-script.py", line 11, in <module> load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')() File "C:\Python35\lib\site-packages\pkg_resources\__init__.py", line 565, in load_entry