Никак не получается подвязать многопоточность к одной из моих функций в программе. Программа просто не реагирует на нажатие кнопки.Пытался изменить значение "change_value" на значение переменной "lineEdit_2" - тот же самый результат.В чем моя ошибка?
import urllib.request
import time
import json
import socket
import requests, sys
import ipaddress
from urllib.request import Request, urlopen
import os
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox, QLineEdit
from PyQt5.QtCore import QThread,pyqtSignal
#Сигнал
class mythread(QThread):
change_value = pyqtSignal(int)
claw)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(2)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def showMessageBox(self,title,messege):
msgBox = QtGui.QMessegeBox()
msgBox.setIcon(QtGui.QMessegeBox.Warning)
msgBox.setWindowTitle(title)
msgBox.setText(messege)
msgBox.setStandardButtons(QtGui.QMessageBox.Ok)
msgBox.exce_()
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "Punch!"))
self.label.setText(_translate("MainWindow", " IP"))
self.label_2.setText(_translate("MainWindow", " Work place"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "Whois Function"))
self.pushButton_3.setText(_translate("MainWindow", "Punch!"))
self.label_5.setText(_translate("MainWindow", " IP"))
self.label_6.setText(_translate("MainWindow", " Work place"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("MainWindow", "Port Scanner "))
self.label_3.setText(_translate("MainWindow", " IP"))
self.label_4.setText(_translate("MainWindow", " Work place"))
self.pushButton_2.setText(_translate("MainWindow", "Punch!"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "Blacklists checkout "))
## Ниже функция
def run(self):
mas = [20, 21, 22, 23, 25, 42, 43, 53, 67, 69, 80, 110, 115, 123, 137, 138, 139, 143, 161, 179, 443, 445,
514, 515,
993, 995]
host = self.lineEdit_2.text()
try:
ipaddress.ip_network(host)
for port in mas:
s = socket.socket()
s.settimeout(1)
try:
s.connect((host, port))
time.sleep(1.5)
per2 = (str(port) + ' port open!')
self.textEdit_5.setText(per2)
print(per2)
except socket.error:
per3 = (str(port) + ' port locked!')
self.textEdit_5.append(per3)
except ValueError:
QMessageBox.warning(self, 'Error!', 'Invalid IP!')
class Window(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super(Window, self).__init__()
self.setupUi(self)
# self.pushButton_2.clicked.connect(self.list)
# self.pushButton.clicked.connect(self.whois)
self.pushButton_3.clicked.connect(self.run)
#Подключение к потоку
def stp(self):
self.thread = mythread()
self.self.change_value.connect(self.run)
self.thread.start()
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
app.setStyle('Fusion')
w = Window()
w.show()
sys.exit(app.exec_())