Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.07 KB | None | 0 0
  1. import sys
  2. import time
  3. from GUI import *
  4. from PyQt5 import QtCore, QtGui, QtWidgets
  5. from threading import Thread
  6.  
  7. class MyWin(QtWidgets.QMainWindow):
  8.     #d = [
  9.     #{'id': 1, 'quest': 'здесь вопрос ', 'answers': (1, 2, 3, 4), 'right_answer': 2-1},
  10.     #{'id': 2, 'quest': 'здесь вопрос ', 'answers': (1, 2, 3, 4), 'right_answer': 4-1}
  11.     #]
  12.  
  13.     def __init__(self,parent=None):
  14.         QtWidgets.QWidget.__init__(self,parent)
  15.         self.ui = Ui_MainWindow()
  16.         self.ui.setupUi(self)
  17.  
  18.         Tlogic = Thread(target=Qlogic.start,args=(self))
  19.         Tlogic.start();
  20.         #@Tlogic.join()
  21.  
  22.         self.ui.pushButton.clicked.connect(self.MyFunction)
  23.  
  24.     def MyFunction(self):
  25.        string = ''
  26.        for question in self.d:
  27.            string += question["quest"]
  28.        self.ui.textEdit.setText(string)
  29.  
  30. class Qlogic(object):
  31.     answer = None
  32.     d = [
  33.     {'id': 1, 'quest': 'Вопрос 1 ', 'answers': ("Smile", "Smile", "Smile", "Smile"), 'right_answer': 2-1},
  34.     {'id': 2, 'quest': 'Вопрос 2', 'answers': ("Smile", "Smile", "Smile", "Smile"), 'right_answer': 4-1}
  35.     ]
  36.     def start(self):
  37.         string =''
  38.         for question in Qlogic.d:
  39.             string = question["quest"] +"\n" +question["answers"][0]+ "\n"+question["answers"][1]+"\n"+question["answers"][2]+"\n"+question["answers"][3]
  40.             self.ui.textEdit.setText(string)
  41.             while(Qlogic.answer == None):
  42.                 time.sleep(1)
  43.             answer = None
  44.  
  45. if __name__ == "__main__":
  46.     app = QtWidgets.QApplication(sys.argv)
  47.     myapp = MyWin()
  48.     myapp.show()
  49.  
  50.     sys.exit(app.exec_())
  51.  
  52. #Log
  53. #Exception in thread Thread-6:
  54. #Traceback (most recent call last):
  55. #  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\threading.py", line 926, in _bootstrap_inner
  56. #    self.run()
  57. #  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\threading.py", line 870, in run
  58. #    self._target(*self._args, **self._kwargs)
  59. #TypeError: start() argument after * must be an iterable, not MyWin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement