Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. import sys
  2. import subprocess
  3. from PyQt6 import QtWidgets, uic
  4. from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot, QThread
  5.  
  6.  
  7. class Action(QObject):
  8.     runProcess = pyqtSignal(str)
  9.  
  10.     @pyqtSlot()
  11.     def RunProcess(self):
  12.         process = subprocess.Popen(["nmap\\ncat.exe", "-lvkp", "666"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
  13.                                    creationflags=0x08000000, universal_newlines=True, encoding="utf8", errors="ignore")
  14.  
  15.         while (True):
  16.             output = process.stdout.readline()
  17.             window.chat_console.insertPlainText(output)
  18.             print(output)
  19.             QtWidgets.QApplication.processEvents()
  20.  
  21.  
  22. class MainWindow(QtWidgets.QMainWindow):
  23.     def __init__(self, *args, **kwargs):
  24.         super().__init__(*args, **kwargs)
  25.         uic.loadUi(f"gui.ui", self)
  26.  
  27.         self.show()
  28.  
  29.         self.action = Action()
  30.         self.thread = QThread(self)
  31.         self.action.runProcess.connect(Action.RunProcess)
  32.         self.action.moveToThread(self.thread)
  33.         self.thread.started.connect(self.action.RunProcess)
  34.         self.thread.start()
  35.  
  36.  
  37. app = QtWidgets.QApplication(sys.argv)
  38. window = MainWindow()
  39. app.exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement