document property of wx.lib.iewin.IEHtmlWindow

During an attempt to convert my existing web scrapping script to the wxPython 2.5.1.5
I have decided to use IEHtmlWindow instead of activexwrapper.
Events work fine but when I try to reference 'document' property of IEHTMLWindow I get following error:

Document Complete: http://wxpython.org/
Traceback (most recent call last):
  File "C:\Documents and Settings\play\Desktop\ie.py", line 30, in OnDocumentComplete
    doc = self.ie.document
  File "C:\python\Python23\lib\site-packages\wx\lib\iewin.py", line 247, in _get_Document
    return self.GetAXProp('Document')
  File "C:\python\Python23\lib\site-packages\wx\activex.py", line 321, in GetAXProp
    return _activex.ActiveXWindow_GetAXProp(*args, **kwargs)
TypeError: Unable to convert value to expected type: (VT_EMPTY) for property <Document>

Any suggestions?
By the way I am using Win 2000/Python 2.3/wxPython 2.5.1.5

waldek

···

#------------------------------------------------------------------------------------
import wx
from wx.lib import iewin

class IEPanel(wx.Window):
    def __init__(self, parent, frame):
        wx.Window.__init__(self, parent, -1)
                   self.current = "http://wxpython.org/"
        self.frame = frame

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.ie = iewin.IEHtmlWindow(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE)
        sizer.Add(self.ie, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(iewin.EVT_DocumentComplete, self.OnDocumentComplete, self.ie)

        self.ie.LoadUrl(self.current)

    def OnSize(self, evt):
        self.Layout()

    def OnDocumentComplete(self, evt):
        URL = evt.URL
        print 'Document Complete: %s' %evt.URL
        if URL==self.current:
            doc = self.ie.document
            print dir(doc)

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = wx.Frame(None, -1, "Test IE")
    IEPanel(frame, -1)
    frame.Show(True)
    app.MainLoop()

#------------------------------------------------------------------------------------

Waldemar Osuch wrote:

During an attempt to convert my existing web scrapping script to the wxPython 2.5.1.5
I have decided to use IEHtmlWindow instead of activexwrapper.
Events work fine but when I try to reference 'document' property of IEHTMLWindow I get following error:

Document Complete: http://wxpython.org/
Traceback (most recent call last):
File "C:\Documents and Settings\play\Desktop\ie.py", line 30, in OnDocumentComplete
   doc = self.ie.document
File "C:\python\Python23\lib\site-packages\wx\lib\iewin.py", line 247, in _get_Document
   return self.GetAXProp('Document')
File "C:\python\Python23\lib\site-packages\wx\activex.py", line 321, in GetAXProp
   return _activex.ActiveXWindow_GetAXProp(*args, **kwargs)
TypeError: Unable to convert value to expected type: (VT_EMPTY) for property <Document>

Oops, that error message is incorrect. Anyway the problem is that the new activex module doesn't have the ability yet to put an automatic wrapper class around VT_DISPATCH COM objects.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!