pyqt

PyQt5 QScrollArea widget with dynamically created GroupBoxes

时光总嘲笑我的痴心妄想 提交于 2020-12-26 13:58:44
问题 I'm trying to make a toolbox widget that will do various different things. But I'm having trouble with the layout management regarding the QScrollArea. Following the stripped version of the code I have: from PyQt5 import QtWidgets import sys class MyScrollWidget(QtWidgets.QWidget): def __init__(self): super(MyScrollWidget, self).__init__() scrollArea = QtWidgets.QScrollArea(self) top_widget = QtWidgets.QWidget() top_layout = QtWidgets.QVBoxLayout() for i in range(10): group_box = QtWidgets

PyQt5 QScrollArea widget with dynamically created GroupBoxes

送分小仙女□ 提交于 2020-12-26 13:39:23
问题 I'm trying to make a toolbox widget that will do various different things. But I'm having trouble with the layout management regarding the QScrollArea. Following the stripped version of the code I have: from PyQt5 import QtWidgets import sys class MyScrollWidget(QtWidgets.QWidget): def __init__(self): super(MyScrollWidget, self).__init__() scrollArea = QtWidgets.QScrollArea(self) top_widget = QtWidgets.QWidget() top_layout = QtWidgets.QVBoxLayout() for i in range(10): group_box = QtWidgets

Threading with QRunnable - Proper manner of sending bi-directional callbacks

和自甴很熟 提交于 2020-12-26 07:56:24
问题 From a tutorial, I've seen that signals and slots can be used to make callbacks from a worker thread into the main GUI thread, but I'm uncertain how to establish bi-directional communication using signals and slots. The following is what I am working with: class RespondedToWorkerSignals(QObject): callback_from_worker = pyqtSignal() class RespondedToWorker(QRunnable): def __init__(self, func, *args, **kwargs): super(RespondedToWorker, self).__init__() self._func = func self.args = args self

How to render a part of QGraphicsScene and save It as image file PyQt5

こ雲淡風輕ζ 提交于 2020-12-26 04:57:11
问题 Suppose I have QGraphicsPixmapItem from loaded image which is added to QGraphicsScene . And suppose I'll add several QGraphicsPolygonItem 's on scene. How I can render a part of the scene as full-size image both with polygons that are not in blank area and save this area as image file. class ImageView(QtWidgets.QGraphicsView): def __init__(self, parent): super(ImageView, self).__init__(parent) self.setFocus() self._zoom = 0 self._empty = True self.scene = QtWidgets.QGraphicsScene(self) self.

Double right-click listener for a QTableWidget

为君一笑 提交于 2020-12-26 04:02:45
问题 I have a PyQt5 QTableWidget for which I want to detect double-right-click events. Here is my 'design.py' module: from PyQt5 import QtCore, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(790, 472) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.tbwMain = QtWidgets.QTabWidget(self.centralwidget) self.tbwMain.setGeometry(QtCore.QRect(0, 0, 801, 451)) self

menuBar() in PyQt5

倖福魔咒の 提交于 2020-12-25 01:57:19
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError:

menuBar() in PyQt5

99封情书 提交于 2020-12-25 01:42:49
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError:

menuBar() in PyQt5

别说谁变了你拦得住时间么 提交于 2020-12-25 01:40:36
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError:

menuBar() in PyQt5

混江龙づ霸主 提交于 2020-12-25 01:40:22
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError:

how can I clear a pyqt QTableWidget?

依然范特西╮ 提交于 2020-12-25 01:10:10
问题 I want to clear my QTableWidget. First of all I select a user in a qcombobox after that I click a qpushbutton and I populate it from database records; when I select other user and I click the qpushbutton to add data I try to clear with: self.tableFriends.clear() The data disappears but the rows remain. The code I populate with is: def getFriends(self): id_us = self.cbUser.itemData(self.cbUser.currentIndex()).toPyObject() rowIndex = 0 self.tableFriends.clear() for row in self.SELECT_FRIENDS(id