I am currently running a PyQt5 application with ipython, but the GUI is frozen after I start some time-consuming commands on the ipython console.
The closest answer that I could find is from How to have Qt run asynchroneously for interactive use like Matplotlib's ion mode? . However, the provided answer there does not solve my problem.
I created a similar example based on the previous post.
from PyQt5.QtWidgets import QApplication, QGraphicsRectItem, QGraphicsScene, QGraphicsView, QMainWindow
import time
%gui qt5
class Rect(QGraphicsRectItem):
def mousePressEvent(self, event):
print("foo")
window = QMainWindow()
window.setGeometry(100, 100, 400, 400)
view = QGraphicsView()
scene = QGraphicsScene()
rect = Rect(0, 0, 150, 150)
scene.addItem(rect)
view.setScene(scene)
window.setCentralWidget(view)
window.show()
time.sleep(1000) # Suppose we are running some other commands on ipython console, then the GUI freezes