PyQt5 interface for posting output of external python program

Viewed 20

So I have created this program in python to make a socket connection with another device, its working but I want to place the definition in pyqt5 interface but hitting a brick wall.

does anyone have a simple example to create a pyqt5 interface that imports my python program and runs the definition while posting its output? Here is a fraction of my code, I realize I may have to sys.stdout my print statements.

# -*- coding: utf-8 -*-
"""
Created on Wed Aug 17 16:04:48 2022

@author: GigaGame
"""
import socket,os,time
import subprocess
import io
import sys

#### make sure ./Software/MTS/filter_wheel/fw102c_control.py is running in moba first#########
###### make sure your ip is set in program###########
###############################################
#def flush_then_wait():
 #           sys.stdout.flush()
  #          sys.stderr.flush()
   #         time.sleep(0.5)
def RDES():
    T=0
    while True:

        while T==0:
            time.sleep(3)
            HOST = ''
            PORT2 = 20134
            
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            
            print('Socket created')
            
            try:
                    l=s.bind((HOST, PORT2))
                    print(l)
            except socket.error as msg:
                    print('Bind failed.')
                    
                    
                    sys.exit()
                    
            print('Socket bind complete')
            s.listen(10)
            print('Socket now listening')
            conn, addr = s.accept()
            print('Connected to ' + addr[0] + ':' + str(addr[1]))
            
        ###################################################
            T2='myturn'
            k=''
            y=1
            T=1
            data=''
            
        while T==1:
                
                if T2=='myturn':
                    #print("weprint") test ptint
                    
                    data = conn.recv(2042)
                    line = data.decode('utf-8')
                    .....
0 Answers
Related