From: Steven on
I am calling a ruby program from a python gui and using
subprocess.Popen in Windows XP using python 2.6. Unfortunately,
whenever the ruby program is called a blank command window appears on
screen, annoying my users. Is there a way to suppress this behaviour?

Below is a minimal program that demonstrates the problem. The problem
does not manifest if the python program is launched via the command
line. To duplicate launch from Windows Explorer by double-clicking on
the python file.

--- call_double.pyw ---
from subprocess import *
import time

time.sleep(3) # to show that command window is result of call to Popen
p = Popen(['ruby.exe', 'double.rb'], stdin=PIPE, stdout=PIPE,
stderr=PIPE)
results = open('results.txt', 'w')
for n in range(10):
p.stdin.write("%d\n" % n)
result = p.stdout.readline().strip()
results.write('double(%s) => %2s\n' % (n, result))
results.close()

--- end of call_double.pyw ---

--- double.rb ---
while true
puts $stdin.gets().strip!.to_i * 2
STDOUT.flush
end
--- end of double.rb ---

thanks for any help,
Steven Rumbalski