open pdf files from with the wxpython app

Hi Robin

Thanks a lot for that … I am able to make internet explorer activex component work gr8 for pdf files…

import sys, os
import wx
if wx.Platform == ‘WXMSW’:
import wx.lib.iewin as iewin
class main_window(wx.Frame):
def init(self, parent, id, title):
wx.Frame.init(self, parent, -1, title, size = (700, 600),
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
self.panel1 = wx.Panel(id=800, name=‘panel1’,
parent=self, pos=wx.Point(0, 0), size=wx.Size(709, 689),
style=wx.TAB_TRAVERSAL)
self.ie = iewin.IEHtmlWindow(self.panel1, -1, size=wx.Size(709, 689),style = wx.NO_FULL_REPAINT_ON_RESIZE)

     self.ie.LoadUrl("C:/test.pdf")
     self.Show(1);self.Hide();self.Show(1)

class App(wx.App):
def OnInit(self):
frame = main_window(None, -1, “wxPython: (A Demonstration)”)
self.SetTopWindow(frame)
return True
app = App(0)
app.MainLoop()

cheers

···

Thomas Thomas

phone +64 7 855 8478
fax +64 7 855 8871

I think that I would approach it a little differently, with a bit more flexibility. I'd make a function in Python that accepts a string, and then you can call that from your PyRun_SimpleString (or get a reference to the function and call it directly via the API.) Then in the function you can do whatever you like to pass the string over to the GUI thread. (posting an event, using wx.CallAfter, etc.)

Thanks Robin,

I'd like to try doing it that way. Can you give me a few lines of code indicating how you would pass a python function reference into a C extension and call it from the API?

-mike

- mike

Okay, I think I got it :

In the C extension:

void PythonPrint(char* str){

         PyObject *PGCommonModule;
         PyObject *printFun;

         Py_Initialize();
         PGCommonModule = PyImport_Import(PyString_FromString("PGCommon"));

         if(PGCommonModule){
                 if (PyObject_HasAttrString(PGCommonModule, "PrintFromExtension")) {
                         printFun = PyObject_GetAttrString(PGCommonModule, "PrintFromExtension");
                         if (PyCallable_Check(printFun)) {
                                 PyObject_CallFunction(printFun, "s", str);
                                 Py_DECREF(printFun);
                         }
                         else printf("Error -- 3. PrintFromExtension is not a function\n");
                 }
                 else printf("Error -- 2. Module dict does not contain PrintFromExtension attribute.\n");
         Py_DECREF(PGCommonModule);
         }
         else printf("Error -- 1. Could not load module PGCommon");

In PGCommon.py:

def PrintFromExtension(str):
     print str

···

-----------------------------------
Now all I have to do is deal with thread/event handling from within PrintFromExtension...

Are there any lurking issues I am not seeing? Thanks again for your help.

-mike

At 11:27 AM 5/26/2006, you wrote:

I think that I would approach it a little differently, with a bit more flexibility. I'd make a function in Python that accepts a string, and then you can call that from your PyRun_SimpleString (or get a reference to the function and call it directly via the API.) Then in the function you can do whatever you like to pass the string over to the GUI thread. (posting an event, using wx.CallAfter, etc.)

Thanks Robin,

I'd like to try doing it that way. Can you give me a few lines of code indicating how you would pass a python function reference into a C extension and call it from the API?

-mike

- mike

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org