SHARE
TWEET

Untitled

a guest Jan 12th, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def update(self, str1):
  2.     str2 = json.loads(str1)
  3.     for i in range(0, len(str2['response'])):
  4.         self.tablewidget.insertRow(self.tablewidget.rowCount())
  5.         print(str2['response'][i]['text'])
  6.         self.tablewidget.setItem(self.tablewidget.rowCount()-1, 0, QTableWidgetItem(str2['response'][i]['text']))
  7.  
  8. def do_(self):
  9.  
  10.     if not(not self.text1.toPlainText() or self.text1.toPlainText().isspace() or not self.text2.toPlainText() or self.text2.toPlainText().isspace()):
  11.         if self.progress.value()==100 or self.progress.value()==0:
  12.             self.thread = QtCore.QThread(self)
  13.             self.my = myClass()
  14.             self.my.moveToThread(self.thread)
  15.  
  16.             self.thread.started.connect(self.my.User_find)
  17.             self.my.finished.connect(self.thread.quit, QtCore.Qt.BlockingQueuedConnection)
  18.             self.my.finished.connect(self.my.deleteLater, QtCore.Qt.BlockingQueuedConnection)
  19.             self.thread.finished.connect(self.thread.deleteLater, QtCore.Qt.BlockingQueuedConnection)
  20.             self.my.message.connect(self.update, QtCore.Qt.BlockingQueuedConnection)
  21.  
  22.             self.my.sendGlobalVar.connect(self.my.receiveID, QtCore.Qt.DirectConnection)
  23.             self.my.sendGlobalVar.emit(self.text1.toPlainText(), self.text2.toPlainText())
  24.  
  25.             self.my.progress.connect(self.progress.setValue)
  26.  
  27.             self.thread.start()
  28.         else: self.msg2.exec()
  29.     else: self.msg1.exec()    
  30.  
  31. class myClass(QtCore.QObject):
  32.  sendGlobalVar = QtCore.pyqtSignal(str, str)
  33.  finished = QtCore.pyqtSignal()
  34.  message = QtCore.pyqtSignal(str)
  35.  progress = QtCore.pyqtSignal(int)
  36.  
  37.  globalVar1 = None
  38.  globalVar2 = None
  39.  
  40.  def receiveID(self, txt1, txt2):
  41.     global globalVar1
  42.     global globalVar2
  43.     globalVar1 = txt1
  44.     globalVar2 = txt2            
  45.  
  46.  @QtCore.pyqtSlot()
  47.  def User_find(self):
  48.     for f in range(0, 100):
  49.         url="https://api.vk.com/method/execute.getCommentsFromPosts?owner_id=%s&user_id=%s&offset=%s&v=5.60&access_token=cbdec60d5c86bae2c89a75d93beea161bece3263f57b3d6eb052c81894f4c85311e778ecd18334f28d89e" % (globalVar1, globalVar2, f*4)
  50.         self.message.emit(requests.get(url).text)
  51.         self.progress.emit(f+1)
  52.     self.finished.emit()
RAW Paste Data
Top