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

Deepak deepak9999 at mail.com
Fri Jul 6 00:29:50 EDT 2001


Hi,
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('myTkinterApp.py')");
}

The code in Python script (myTkinterApp.py) is like this: -

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


The result is that it prints: -

Tkinter successfully imported
failed

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.
Deepak



More information about the Python-list mailing list