pyside

QPixmap: It is not safe to use pixmaps outside the GUI thread

人走茶凉 提交于 2019-12-25 09:50:40
问题 I am using PySide to make a GUI application. I have 3 classes: A QWidget class, a QThread Worker class and a controller for the Worker class. The GUI class creates a controller object that spawns a given number of worker threads, in that hierarchy: class Worker(QtCore.QThread): # Signal that tells the controller the current progress of the # thread. sig_worker_update_progress = QtCore.Signal(int, int) def __init__(self, thread_id, *args, **kwargs): super(Worker, self).__init__(*args, **kwargs

PyQt - Hide MainWindow and show QDialog without the taskbar icon disappearing

空扰寡人 提交于 2019-12-25 09:02:13
问题 I've been using the code from this example PyQt: How to hide QMainWindow: class Dialog_02(QtGui.QMainWindow): def __init__(self, parent): super(Dialog_02, self).__init__(parent) # ensure this window gets garbage-collected when closed self.setAttribute(QtCore.Qt.WA_DeleteOnClose) ... def closeAndReturn(self): self.close() self.parent().show() class Dialog_01(QtGui.QMainWindow): ... def callAnotherQMainWindow(self): self.hide() self.dialog_02 = Dialog_02(self) self.dialog_02.show() It works,

Creating a Marquee effect in PySide

本小妞迷上赌 提交于 2019-12-25 08:48:25
问题 How would I be able to create a marquee effect in a PySide Label in Python? I have some news headlines in a list and I would like them to scroll across the bottom of the window. 回答1: You could create a custom widget but to avoid the task of implementing many methods takes advantage of the QLabel class as shown below: class MarqueeLabel(QLabel): def __init__(self, parent=None): QLabel.__init__(self, parent) self.px = 0 self.py = 15 self._direction = Qt.LeftToRight self.setWordWrap(True) self

PySide: base on the groupbox example of PySide-Example , issue An error native Qt signal is not callable [duplicate]

会有一股神秘感。 提交于 2019-12-25 04:54:25
问题 This question already has answers here : PySide : How to get the clicked QPushButton object in the QPushButton clicked slot? (4 answers) Closed 5 years ago . Base on the groupbox example of PySide-Example, I add a clicked slot to the pushButton , such as: def createPushButtonGroup(self): ... pushButton = QtGui.QPushButton("&Normal Button") pushButton.clicked(self.normalClick) ... def normalClick(self): print self.sender.pushButton.text() But it issues an error: TypeError: native Qt signal is

Waiting for a timer to terminate before continuing running the code

大城市里の小女人 提交于 2019-12-25 03:16:31
问题 The following code updates the text of a button every second after the START button was pressed. The intended functionality is for the code to 'wait' until the timer has stopped before continuing on with the execution of the code. That is, after START is pressed, the text of the second button is incremented to 3 , and only then should the text I waited! appear on the console. import sys from PySide import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self, parent=None): super

Qt Stylesheets - how to remove dead space

纵饮孤独 提交于 2019-12-25 02:31:44
问题 I am creating a simple plotting application using PySide and have a problem with loads of dead space. How can I remove all this extra padding using stylesheets (preferably) or programmatically? I've tried setting margins and padding on QFrame to 0, but with little effect. I'm using layouts for positioning and my widgets inherit from QFrame and generally contain other widgets such as QTabWidget, QListWidget etc.. (I have avoided the use of QWidget as I believe this is not fully supported by Qt

PySide: Movable labels snap back to original position when released. Trying to make them move freely

岁酱吖の 提交于 2019-12-24 19:22:07
问题 The following code implements 5 movable labels. When I try to change the color of the labels while they are being moved, the labels snap back to the original position when the mouse button is released. When you comment out the part where setStyleSheet is used, it works and the labels are able to move and be released freely. import sys from PySide import QtGui from PySide import QtCore from PySide.QtGui import * from PySide.QtCore import * from Drag import Ui_Dialog class MainWindow

QAbstratctTableModel - removeRows

安稳与你 提交于 2019-12-24 18:27:59
问题 Code is almost complete. Here's the deal: It is python and PySide. I have a QAbstractTableModel and a QTableView. I cant get deleting rows correctly. I think the problem is somewhere in the indexes of the rows onde I delete one of them... here is the button delegate I use: class ButtonDelegate(QItemDelegate): def __init__(self, parent): QItemDelegate.__init__(self, parent) def paint(self, painter, option, index): widget = QWidget() layout = QHBoxLayout() widget.setLayout(layout) btn =

How to refresh QTableView when it is driven by model

痴心易碎 提交于 2019-12-24 18:12:33
问题 The code below creates QTableView driven by self.myModel ( QAbstractTableModel ). 'Show All' self.checkBox is linked to self.myModel.cbChanged() method. Question: How to modify this code so 'QTableView' gets refreshed as soon as checkbox is checked? The goal: when the checkbox is checked we want the odd numbered items to be displayed. And the even numbered items to be hidden. When the checkbox is off (unchecked) we want the even numbered items to be displayed. All the odd numbered items are

How can i make ipythons RichIPythonWidget use pyside in a pyinstaller environment?

匆匆过客 提交于 2019-12-24 17:19:23
问题 I have an application that i build using pyinstaller, and it uses PySide for its Qt Gui. I included an interactive prompt by embedding an ipython qtconsole. This breaks the builds created by pyinstaller. Here is a minimal (non-)working example: from PySide.QtGui import * from IPython.qt.console.rich_ipython_widget import RichIPythonWidget from IPython.qt.inprocess import QtInProcessKernelManager from IPython.lib import guisupport class IPythonWidget(RichIPythonWidget): def __init__(self,