Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import subprocess
- from PyQt6 import QtWidgets, uic
- from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot, QThread
- class Action(QObject):
- runProcess = pyqtSignal(str)
- @pyqtSlot()
- def RunProcess(self):
- process = subprocess.Popen(["nmap\\ncat.exe", "-lvkp", "666"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- creationflags=0x08000000, universal_newlines=True, encoding="utf8", errors="ignore")
- while (True):
- output = process.stdout.readline()
- window.chat_console.insertPlainText(output)
- print(output)
- QtWidgets.QApplication.processEvents()
- class MainWindow(QtWidgets.QMainWindow):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- uic.loadUi(f"gui.ui", self)
- self.show()
- self.action = Action()
- self.thread = QThread(self)
- self.action.runProcess.connect(Action.RunProcess)
- self.action.moveToThread(self.thread)
- self.thread.started.connect(self.action.RunProcess)
- self.thread.start()
- app = QtWidgets.QApplication(sys.argv)
- window = MainWindow()
- app.exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement