PyQt5 QThread Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
Demosthenes Koptsis
demosthenesk at gmail.com
Wed Jun 30 12:26:19 BST 2021
Hello,
i have a GUI with PyQt5. The GUI has a Form, 2 Buttons and a
ProgressBar. I want to implement a start/wait thread with QThread.
Unfortunately i get Process finished with exit code 139 (interrupted by
signal 11: SIGSEGV) when i click Run button to run thread.
MainWindow.py
-------------------------------------------
|# -*- coding: utf-8 -*- # Form implementation generated from reading ui
file 'MainWindow.ui' # # Created by: PyQt5 UI code generator 5.15.4 # #
WARNING: Any manual changes made to this file will be lost when pyuic5
is # run again. Do not edit this file unless you know what you are
doing. from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Form(object):
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(400,
138) self.btnRun = QtWidgets.QPushButton(Form)
self.btnRun.setGeometry(QtCore.QRect(20, 20, 89, 25))
self.btnRun.setObjectName("btnRun") self.btnStop =
QtWidgets.QPushButton(Form) self.btnStop.setGeometry(QtCore.QRect(20,
60, 89, 25)) self.btnStop.setObjectName("btnStop") self.progressBar =
QtWidgets.QProgressBar(Form)
self.progressBar.setGeometry(QtCore.QRect(20, 100, 371, 23))
self.progressBar.setProperty("value", 24)
self.progressBar.setObjectName("progressBar") self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self,
Form): _translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Test Thread"))
self.btnRun.setText(_translate("Form", "Run"))
self.btnStop.setText(_translate("Form", "Stop")) |
|---------------------------------------------------------------|
When i click the Start button the application crashes with segmentation
fault.
Thread.py
|---------------------------------------------------------------|
|from PyQt5.QtWidgets import * from PyQt5.QtCore import * from
MainWindow import * import sys import time class MainWindow(QWidget,
QThread): def __init__(self, parent=None): super(MainWindow,
self).__init__(parent) self.ui = Ui_Form() self.ui.setupUi(self)
self.center() #Init progressBar self.ui.progressBar.setValue(0) #Buttons
self.ui.btnRun.clicked.connect(self.start)
self.ui.btnStop.clicked.connect(self.wait) def run(self): count = 0
while count <= 100: count += 1 self.ui.progressBar.setValue(count)
time.sleep(1) def center(self): # geometry of the main window qr =
self.frameGeometry() # center point of screen cp =
QDesktopWidget().availableGeometry().center() # move rectangle's center
point to screen's center point qr.moveCenter(cp) # top left of rectangle
becomes top left of window centering it self.move(qr.topLeft()) if
__name__ == '__main__': app = QApplication(sys.argv)
app.setAttribute(Qt.AA_DontShowIconsInMenus, False) w = MainWindow() #
Disable maximize window button w.setWindowFlags(Qt.WindowCloseButtonHint
| Qt.WindowMinimizeButtonHint) w.show() sys.exit(app.exec_())
--------------------------------------------------------------- |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210630/23f4f097/attachment-0001.htm>
More information about the PyQt
mailing list