[PySide] Error on Ubuntu but not Windows
Jim Byrnes
jf_byrnes at comcast.net
Sat Dec 13 21:55:18 CET 2014
I am running Ubuntu 12.04, PySide 1.2.2.
I am just getting started with PySide and have been watching a series of
video tutorials. In the video on threading there is the following program.
from PySide.QtCore import *
from PySide.QtGui import *
import sys
import showGui
import time
import showGui
class MainDialog(QDialog, showGui.Ui_mainDialog):
def __init__(self, parent=None):
super(MainDialog, self).__init__(parent)
self.setupUi(self)
self.showButton.setText("Process")
self.connect(self.showButton, SIGNAL("clicked()"),
self.processData)
self.workerThread = WorkerThread()
self.connect(self.workerThread, SIGNAL("threadDone(QString,
QString)"), self.threadDone, Qt.DirectConnection)
def processData(self):
self.workerThread.start()
QMessageBox.information(self, "Done!", "Done.")
def threadDone(self, text, text2):
# Does not work. Gives pixmaps error
#QMessageBox.warning(self, "Warning!", "Thread execution
completed!")
# Works as expected
self.nameEdit.setText("Worker thread finished processing.")
print text
print text2
class WorkerThread(QThread):
def __init__(self, parent=None):
super(WorkerThread, self).__init__(parent)
def run(self):
time.sleep(3)
self.emit(SIGNAL("threadDone(QString, QString)"), "Confirmation
that the thread is finished.", "Another confirmation that the thread has
been compledted.")
app = QApplication(sys.argv)
form = MainDialog()
form.show()
app.exec_()
In the threadDone method uncommenting the QMessageBox line produces the
following error message:
QObject::setParent: Cannot set parent, new parent is in a different thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
X Error: BadImplementation (server does not implement operation) 17
Major opcode: 20 (X_GetProperty)
Resource id: 0x0
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has
not been called
[xcb] Aborting, sorry about that.
python2.7: ../../src/xcb_io.c:274: poll_for_event: Assertion
`!xcb_xlib_threads_sequence_lost' failed.
Process finished with exit code 134
In the video the presenter is running Windows 8 and it worked for him.
Is this a known problem or am I just doing something wrong? I don't
have a window machine to try it locally.
Thanks, Jim
More information about the PySide
mailing list