Skip to main content

Posts

Showing posts with the label Python

python process real time output

Real Time Output Issue resolved: I did encountered similar issue in Python, while capturing the real time output from c program. I added " fflush(stdout) ;" in my C code. It worked for me. Here is the snip the code << C Program >> #include <stdio.h> void main () { int count = 1 ; while ( 1 ) { printf ( " Count %d\n" , count ++); fflush ( stdout ); sleep ( 1 ); } } << Python Program >> #!/usr/bin/python import os , sys import subprocess procExe = subprocess . Popen ( ".//count" , shell = True , stdout = subprocess . PIPE , stderr = subprocess . PIPE , universal_newlines = True ) while procExe . poll () is None : line = procExe . stdout . readline () print ( "Print:" + line ) << OUTPUT>> Print: Count 1 Print: Count 2 Print: Count 3 UPDATE:: The above one has flaws as we are reading only oneline per poll iteratio...

Cross Platform UI application with Python

Today I came to know about the open source software called wxPython . This has basic core libraries for the Windows, MAC, Linux. The user has to write the UI/code in python using these wxPython APIs. These APIs will be common across all platforms. You can easily port this code into other platforms. URL for wxPython: wxPython I am a novice for this.. Some time in future I might use this to create some cross platform apps... There is one more library called tkInter . This also looks cool. There is a python IDE which looks super cool with the black theme i like so much. its called pyCharm