[python-win32] Problems opening windows

Hihn, Jason Jason.Hihn at verint.com
Mon Nov 22 20:08:16 CET 2004


Hi, I have embedded Python in my MFC app, and it works, but it won't
create windows.



Originally I was using PyQt, but I hit my frustration limit and tried
Tk. TK doesn't work for me either. I was hoping someone could shed on
what it takes to open a window from python in an MFC appMFC apps. I'm
hoping these two issues are related. I get no errors or warnings, just
nothing happens.





Here's my source:



void CPyqttestDlg::OnOK()

{

            // TODO: Add extra validation here



//                      PyEval_InitThreads();

            Py_Initialize();

            PyObject *qt[2];

            PyObject *err;

           

            char modules[][80]={"qt", "qtui"};

/*          for (int h=0; h<sizeof(modules)/80; h++){

                        qt[h] =PyImport_ImportModule(modules[h]);

                        err=PyErr_Occurred();

                        if (err)

                                    PyErr_Print();

            }

*/

            char statements[][100]={

                        "import sys\n",


"sys.path.append('C:\\Python23\\Lib\\lib-tk')\n",

                        "from qt import *\n",

                        "from qtui import *\n",



                        "a=QApplication(sys.argv)\n",

                        "a.connect(a, SIGNAL(\"lastWindowClosed()\"), a,
SLOT(\"quit()\"))\n",

                        "x=QDialog()\n",

                        "x.show()\n",

                        "a.exec_loop()\n"};

            char statements2[][100]={

                        "import sys",

                        "sys.path.append('C:\\Python23\\Dlls')",


"sys.path.append('C:\\Python23\\Lib\\site-packages')",

                        "from Tkinter import *",

                        "class Test(Frame):",

                        "    def printit(self):",

                        "   def createWidgets(self):",

                        "           self.QUIT = Button(self,
text='QUIT', foreground='red', "

                        "
command=self.quit)",

                        "           self.QUIT.pack(side=LEFT,
fill=BOTH)",

                        "           self.hi_there = Button(self,
text='Hello', "

                        "
command=self.printit)",

                        "           self.hi_there.pack(side=LEFT)",

                        "    def __init__(self, master=None):",

                        "           Frame.__init__(self, master)",

                        "           Pack.config(self)",

                        "           self.createWidgets()",

                        "test = Test()",

                        "test.mainloop()"};



            char *line;

            for (int i=0; i<sizeof(statements2)/100; i++){       

                        line=statements2[i];

                        //if (AfxMessageBox(line)==MB_OK){

                                    PyRun_SimpleString(line);

                                    TRACE(line);

                                    err=PyErr_Occurred();

                                    if (err)

                                                PyErr_Print();

                        //}



            }



            Py_Finalize();



            CDialog::OnOK();

}



__________________________________________________________________________________________
This electronic message may contain proprietary and confidential information of Verint Systems Inc., its affiliates and/or subsidiaries.
The information is intended to be for the use of the individual(s) or
entity(ies) named above.  If you are not the intended recipient (or authorized to receive this e-mail for the intended recipient), you may not use, copy, disclose or distribute to anyone this message or any information contained in this message.  If you have received this electronic message in error, please notify us by replying to this e-mail. (1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20041122/240da2eb/attachment.htm


More information about the Python-win32 mailing list