Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update(self, str1):
- str2 = json.loads(str1)
- for i in range(0, len(str2['response'])):
- self.tablewidget.insertRow(self.tablewidget.rowCount())
- print(str2['response'][i]['text'])
- self.tablewidget.setItem(self.tablewidget.rowCount()-1, 0, QTableWidgetItem(str2['response'][i]['text']))
- def do_(self):
- if not(not self.text1.toPlainText() or self.text1.toPlainText().isspace() or not self.text2.toPlainText() or self.text2.toPlainText().isspace()):
- if self.progress.value()==100 or self.progress.value()==0:
- self.thread = QtCore.QThread(self)
- self.my = myClass()
- self.my.moveToThread(self.thread)
- self.thread.started.connect(self.my.User_find)
- self.my.finished.connect(self.thread.quit, QtCore.Qt.BlockingQueuedConnection)
- self.my.finished.connect(self.my.deleteLater, QtCore.Qt.BlockingQueuedConnection)
- self.thread.finished.connect(self.thread.deleteLater, QtCore.Qt.BlockingQueuedConnection)
- self.my.message.connect(self.update, QtCore.Qt.BlockingQueuedConnection)
- self.my.sendGlobalVar.connect(self.my.receiveID, QtCore.Qt.DirectConnection)
- self.my.sendGlobalVar.emit(self.text1.toPlainText(), self.text2.toPlainText())
- self.my.progress.connect(self.progress.setValue)
- self.thread.start()
- else: self.msg2.exec()
- else: self.msg1.exec()
- class myClass(QtCore.QObject):
- sendGlobalVar = QtCore.pyqtSignal(str, str)
- finished = QtCore.pyqtSignal()
- message = QtCore.pyqtSignal(str)
- progress = QtCore.pyqtSignal(int)
- globalVar1 = None
- globalVar2 = None
- def receiveID(self, txt1, txt2):
- global globalVar1
- global globalVar2
- globalVar1 = txt1
- globalVar2 = txt2
- @QtCore.pyqtSlot()
- def User_find(self):
- for f in range(0, 100):
- 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)
- self.message.emit(requests.get(url).text)
- self.progress.emit(f+1)
- self.finished.emit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement