Tkinter doesn't work for MFC applications with Embedded Python?

Deepak deepak9999 at
Fri Jul 6 06:29:50 CEST 2001

I tried to go through all the related postings on the newsgroup
regarding this.
However, I haven't figured out a way to get Tkinter working in an MFC
application that uses embedded python interpreter... Here is the
simple code
that I am trying in the MFC application

The code in C is simple like this: -

#include <Python.h>

void myFunc (int argc, char **argv)
   Py_Initialize ();
   PySys_SetArgv (argc, argv);
   PyRun_SimpleString ("execfile('')");

The code in Python script ( is like this: -

   import Tkinter
   print 'Tkinter successfully imported'
      root = Tkinter.Tk ()
      print 'Successful'
      print 'failed'
   print 'Could not import Tkinter'

The result is that it prints: -

Tkinter successfully imported

The STDOUT is redirected to print to one of the MFC windows. 
I tried to run this by changing the STDOUT to default (standard)
STDOUT. However, even that did not help.

Any examples or suggestions will be extremely valuable.

More information about the Python-list mailing list