pyqt

QtSingleApplication for PySide or PyQt

狂风中的少年 提交于 2021-02-04 15:43:47
问题 Is there a Python version of the C++ class QtSingleApplication from Qt Solutions? QtSingleApplication is used to make sure that there can never be more than one instance of an application running at the same time. 回答1: Here is my own implementation. It has been tested with Python 2.7 and PySide 1.1. It has essentially the same interface as the C++ version of QtSingleApplication. The main difference is that you must supply an application unique id to the constructor. (The C++ version by

Adding items to QlistView

↘锁芯ラ 提交于 2021-02-04 14:58:08
问题 I'm using pyqt4 with python 2.7 and I have a list view widget that I can't add items to it # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'add_category.ui' # # Created: Mon Mar 19 23:22:30 2018 # by: PyQt4 UI code generator 4.10 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def

How to change label text until pushbutton clicked in pyqt

血红的双手。 提交于 2021-02-04 08:40:24
问题 how do i change the text of a label until a push button is clicked in pyqt (how do i keep this in loop) here is the code i tried from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui

How to implement zooming image better?

只愿长相守 提交于 2021-02-04 08:22:15
问题 I have the following code: from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel from PyQt5.QtGui import QPixmap from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt import sys class Window(QWidget): def __init__(self): super().__init__() self.imgLabel = QLabel(self) pixmap = QPixmap("feedreader.jpg") self.imgLabel.setPixmap(pixmap) self.imgLabel.setAlignment(Qt.AlignCenter | Qt.AlignCenter) self.imgLabel.setSizePolicy

Qt module alternative for PyQt6

我是研究僧i 提交于 2021-02-04 07:54:21
问题 I'm just migrating my application from PyQt5 to PyQt6. I understand that the Qt module has been removed in Qt6. I have stuff like 'Qt.AlignCenter', 'Qt.ToolButtonTextUnderIcon', 'Qt.LeftToolBarArea', which are no longer working. Is there any alternative for this functionality in Qt6? 回答1: The Qt module only exists in PyQt5 (not in Qt5) that allowed access to any class or element of any submodule, for example: $ python >>> from PyQt5 import Qt >>> from PyQt5 import QtWidgets >>> assert Qt

Qt module alternative for PyQt6

跟風遠走 提交于 2021-02-04 07:53:29
问题 I'm just migrating my application from PyQt5 to PyQt6. I understand that the Qt module has been removed in Qt6. I have stuff like 'Qt.AlignCenter', 'Qt.ToolButtonTextUnderIcon', 'Qt.LeftToolBarArea', which are no longer working. Is there any alternative for this functionality in Qt6? 回答1: The Qt module only exists in PyQt5 (not in Qt5) that allowed access to any class or element of any submodule, for example: $ python >>> from PyQt5 import Qt >>> from PyQt5 import QtWidgets >>> assert Qt

How to add video in UI created using Qt Designer with a promoted widget which is a QVideoWidget?

流过昼夜 提交于 2021-02-04 06:36:50
问题 I am a beginner in Qt. But following some tutorials I created a UI in qt designer which would display a live stream video. I have read that in order to add video i need to promote widget to a QVideoWidget. Then I convert the .ui to a .py file to access it using python language. The thing is once i have done that i dont know how to put the video in the widget that i made in the ui. Thank you. The code below show the GUI.py file. I am importing it in another file where I would code it show the

How to add video in UI created using Qt Designer with a promoted widget which is a QVideoWidget?

青春壹個敷衍的年華 提交于 2021-02-04 06:35:28
问题 I am a beginner in Qt. But following some tutorials I created a UI in qt designer which would display a live stream video. I have read that in order to add video i need to promote widget to a QVideoWidget. Then I convert the .ui to a .py file to access it using python language. The thing is once i have done that i dont know how to put the video in the widget that i made in the ui. Thank you. The code below show the GUI.py file. I am importing it in another file where I would code it show 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

PyQt QToolButton not updating icon when in focus

删除回忆录丶 提交于 2021-02-02 10:12:08
问题 I'm having a problem updating the icon of a button set with QToolButton . The idea is to use the button for a movie player. To play, one presses the button and the icon changes to pause. When pressed again, play is paused and the icon reverts to play. I have some working code, but the problem is that the icon is not updating consistently. If I keep the Qt window in focus, it takes one or two button presses to change the icon to the intended image, by which time the actual image is not the