473,608 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

show in GUI stdout of a command

Hi,

I need to display in real time the output of a command line tool in a
GUI written so far with Tkinter and Pmw. I've got a command line tool
that I want to integrate to a GUI. The parameters are set using the GUI
and a button executes the command. The calc is long so I need to see how
fast it goes. This is given by the stdout...

any idea how to do this?

thanks
Alexandre
Dec 19 '05 #1
2 3363
Try Pexpect for running your command interactively
http://pexpect.sourceforge.net/

For example, if you wanted to run the "top" command you could
use a script like below. This updates the output every 5 seconds.
You can easily adjust the timeout.
---------------------------------------------------------------
import pexpect
def progress_callba ck (d):
"""This callback updates child command output.
This is used when running external commands
with pexpect.run.The callback is given a dictionary
of the local variables in pexpect.run. This explains
the syntax of d['child'].before, which you would
otherwise simple enter as child.before.
"""
print d['child'].before

pexpect.run("to p", timeout=5,
events={pexpect .TIMEOUT:progre ss_callback})
---------------------------------------------------------------

Next you would then have to add that whole
GUI thing yourself :-)

You can also try using pipes (popen and friends), but the
output will be block buffered, so it would come out chunky
and not in real time. There is no way to change the child's
buffering from block buffering to line buffering without using
a pseudo-TTY.

Yours,
Noah

Dec 20 '05 #2
In message <43************ *********@news. free.fr>, twigster
<tw************ @THISmelix.net> writes
Hi,

I need to display in real time the output of a command line tool in a
GUI written so far with Tkinter and Pmw. I've got a command line tool
that I want to integrate to a GUI. The parameters are set using the GUI
and a button executes the command. The calc is long so I need to see
how fast it goes. This is given by the stdout...

any idea how to do this?

thanks
Alexandre


Full of Christmas spirit, I'll suggest a look at
http://lfw.org/python/Console.py
I find it a few days ago when I was hunting for a way to "print" to the
tkinter window rather than stdout.

Regards
--
Ian Parker
Dec 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4657
by: Phil Powell | last post by:
<?php class FileRemoval { var $fileNameArray, $isRemoved, $errorMsg = ''; function FileRemoval() { // CONSTRUCTOR $this->fileNameArray = array(); $this->isRemoved = 0; }
6
5629
by: Tsai Li Ming | last post by:
Dear all, I have a problem with a redirecting stdout and stderr. I am a top level module and has no control over the imported modules that are making system calls such as os.system or popen2.* . I have tried the simplest method of capturing stdout, stderr via: saveout = sys.stdout sys.stdout = file_obj
2
3845
by: Graham Ashton | last post by:
Hi. I'm having trouble flushing sys.stdout. I've written a small example to illustrate my problem (see below). In short, I expect it to ping "received hello", sleep for 5 seconds and then print "received world". Instead I get nothing for 5 seconds and then both statements pop out at once. As you'll no doubt gather from the example, the problem I'm really trying to solve is sending message back from one process to another via a pipe....
1
5374
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
4
6082
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
1
3495
by: Jacek Pop³awski | last post by:
Popen from subprocess module gives me access to stdout, so I can read it. Problem is, that I don't know how much data is available... How can I read it without blocking my program? example: -------------------------------------------------------------------- import subprocess import time command="ls -l -R /"
0
2433
by: Christoph Haas | last post by:
Evening, I'm having trouble with running a process through Python 2.4's subprocess module. Example code: ======================================================== def run(command): run = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the process to return
2
1925
by: gbastian | last post by:
Dear Users, I am trying to recover through the python function popen3 the stdout,in,err of a launched process. I would like also to recover the stdout which you can get only through the command: command1 >& filename Do you know how I can access to that stdout by python?
1
3761
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a C# application in which I start another process which produces output to stdout and stderr. In fact, that process is the uSoft VS2005 C/C++ compiler itself! I would like to capture the results of the compile and display them in a RichTextBox. The problem I'm having is that when I intentionally introduce an error in the C code I'm compiling, I can't read the error output in my C# program. I've tried redirecting both...
0
8063
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8003
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8152
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5476
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1598
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.