If I open a window from the main() method it is displayed correctly.
If I open the same window out of a class instantiated from the main() method (WorkerClass), the window is only partially displayed, all the content inside (e.g. a QText) edit is missing.
Here's the code I used to reproduce this with a minimal amount of code:
import sys, time
from PyQt5.QtWidgets import QApplication, QTextEdit
from PyQt5.QtCore import QObject
class StatusWindow(QTextEdit):
def __init__(self):
super().__init__()
def appendText(self, text):
self.append(text)
class WorkerClass(QObject):
def __init__(self):
super().__init__()
def openWindow(self):
s = StatusWindow()
s.show()
s.appendText('opened from WorkerClass')
time.sleep(10)
def main():
app = QApplication(sys.argv)
win = StatusWindow()
win.show()
win.appendText('opened from main()')
work = WorkerClass()
work.openWindow()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
What goe's wrong here? How to fix this example to be able to get the window opened from WorkerClass displayed correctly?