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

Deepak deepak9999 at mail.com
Fri Jul 6 09:18:22 EDT 2001


Hi,
I am trying to run scripts that use Tkinter for GUI inside of an MFC
application that has embedded python interpreter. I read through the
other postings on this newsgroup regarding the difficulties of doing
so. However, I am not able to figure out what I am doing wrong...

Here is the C code in the MFC application: -

void myFunc (int argc, char **argv)
{
   Py_Initialize ();
   PySys_SetArgv (argc, argv);
   PyRun_SimpleString ("execfile ('myTkinterApp.py')");
}

The contents of myTkinterApp.py are: -
try:
   import Tkinter
   print 'Successfully imported Tkinter'
   try:
      rt = Tkinter.Tk ()
      print 'Successfully executed Tkinter.Tk ()'
   except:
      print 'Error in Tkinter.Tk ()'
except:
   print 'Error importing Tkinter'

The result is printed as: -
Successfully imported Tkinter
Error in Tkinter.Tk ()

The exception thrown is something like "Tkinter.tk could not be
initialized.."
All other scripts and commands run fine in the MFC app. It is only the
Tkinter
based commands that have the problem.
Please help...

Deepak



More information about the Python-list mailing list