I have a threaded program that I want to start using a Python GUI in a UNIX environment. By gathering the output from the C program, I want to change the status of the GUI.
For example, this is output using printf from my C program:
Thread on tile: 2 on thread on the tile: Thread 3 on closed tile: Disabled Thread on tile 61: On current I will update my GUI based on the output. What makes the problem difficult is that both my GUI and C program need to run together And updates in real time let me do the program with my GUI The command should also be able to send.
I am new to Python, C and Unix (I know, full stop status).
I have run this problem in the past (there really is not a satisfactory solution):
As suggested here, Take a look at this custom module:
Richard (Not enough representative for comment): The problem with pipes is that unless they are connected to an interactive terminal, they are completely buffered Are Means that through no one pipe the output to run programming with Python, which is certainly not qualify as real-time. Edit 2: Based on the link of Richard and what I did some earlier, I did it to me to treat it as a file object and only one line at a time It may be possible to manually loop over the pipe by reading:
import time from the sleep # value estimate Popen object is wait_time = 1 # 1 second, the same delay when `Trail: # or Whatever the situation you need line = proc.stdout.readline () There is, if the line! = '' And the line! = '\ N': parse_line_do_stuff) sleep (wait_time) It believes that readline () is non-blocked, and further assumes that the pipes are in the most buffer, and then I can not even try it, I have never tried it.
Comments
Post a Comment