[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    stdout and embedding into Windows apps
From:       Thomas Schreiner <tmp-pythonlist () tschreiner ! org>
Date:       2007-09-19 12:17:30
Message-ID: 46F1135A.3020301 () tschreiner ! org
[Download RAW message or body]

Hi,

I'm extending a windows application (C++) by embedding Python calls. It
seems to be a known problem that windows applications detach immediately
from the calling console, so that all output to stdout (from both C++
and Python) doesn't get shown anywhere.

A workaround seems to be the allocation of a windows console and
redirecting stdout to it:

   AllocConsole();
   freopen("conin$", "r", stdin);
   freopen("conout$", "w", stdout);
   freopen("conout$", "w", stderr);

Still, this console only shows the output of my C++ application, not the
output of the embedded python calls.

The following code
   Py_Initialize();
   std::cout << "start printing..." << std::endl;
   PyRun_SimpleString("print('PRINT')\n");
   std::cout << "done printing." << std::endl;

only prints

   start printing...
   done printing.

Does anybody know how to fix this issue? Basically I want to get an 
ipython console running in the background of my Windows app, so that I 
can process its data.


Cheers,


Thomas

-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic