Winand

Untitled

Sep 3rd, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. from PyQt4 import QtGui, QtCore
  2. import sys, time
  3. thd, thd2 = None, None
  4.  
  5. class T(QtCore.QThread):
  6.     def __init__(self, f):
  7.         super().__init__()
  8.         self.f = f
  9.     def run(self):
  10.         print("running", self.f)
  11.         self.f()
  12.  
  13. def thd_fin():
  14.     print("Fin.")
  15.    
  16. def thd_fin3():
  17.     print("Fin3.")
  18.        
  19. def threadInThread():
  20.     global thd2
  21.     thd2 = T(lambda: None)
  22.     thd2.finished.connect(thd_fin3)
  23.     thd2.start()
  24.     time.sleep(2)
  25.  
  26. class Form(QtGui.QWidget):
  27.     def __init__(self):
  28.         super().__init__()
  29.         global thd
  30.         thd = T(threadInThread)
  31.         thd.finished.connect(thd_fin)
  32.         thd.start()
  33.  
  34. app = QtGui.QApplication(sys.argv)
  35. f = Form()
  36. f.show()
  37. app.exec()
Advertisement
Add Comment
Please, Sign In to add comment