I'm trying to update the QLabel in the GUI with the number, generated in a thread. Can this be done?

Qt Code:
  1. import threading, random, sys
  2. from PyQt5.QtWidgets import *
  3. from PyQt5.QtGui import *
  4. from PyQt5.QtCore import *
  5. from PyQt5 import QtCore, QtTest
  6.  
  7.  
  8. def update():
  9. while True:
  10. n = random.randint(0,22)
  11. QtTest.QTest.qWait(500)
  12.  
  13. threading.Thread(target=update, daemon = True).start()
  14.  
  15. class MainWindow(QMainWindow):
  16.  
  17. def __init__(self, *args, **kwargs):
  18. super(MainWindow, self).__init__(*args, **kwargs)
  19. self.setFixedSize(200, 200)
  20.  
  21. self.labl = QLabel(self)
  22. self.labl.setText("value of n goes here")
  23.  
  24.  
  25. app = QApplication(sys.argv)
  26. window = MainWindow()
  27. window.show()
  28. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode