Subprocess and /usr/bin/dialog

harrelson harrelson at gmail.com
Sat Mar 22 10:31:33 EDT 2008


On Mar 21, 3:59 pm, Grant Edwards <gra... at visi.com> wrote:
> On 2008-03-21, harrelson <harrel... at gmail.com> wrote:
>
> > I am trying to get the below code to work and can't quite make things
> > happen.  This is with Python 2.5.1.  Dialog is doing something odd...
> > I have tinkered with different combinations and I can't get the dialog
> > to show properly-- it does show properly directly in the shell.  Any
> > hints?
>
> > import subprocess
> > command = '/usr/bin/dialog --clear --title "title" --menu "text" 20 50
> > 5 "a" "this and that" "c" "3 this and that" "b" "2 this and that" "d"
> > "4 this and that"'
> > proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
> > stderr=subprocess.STDOUT)
> > #proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
> > stderr_value = proc.communicate()[0]
> > print stderr_value
>
> [It would be helpful if you didn't wrap sample code when you
> post it.]

Sorry I posted through google groups and it wrapped it for me...

> dialog displays the widget on stdout.  You've connected stdout
> to a pipe, so you're not going to see anything displayed unless
> you read data from the stdout pipe and write it to the terminal.

Reading this tutorial on subprocess:

http://blog.doughellmann.com/2007/07/pymotw-subprocess.html

led me to believe this was exactly what I was doing.  The screen does
actually turn blue for a second but it is as if I only get one
keystroke and python is back in control...



More information about the Python-list mailing list