How python ActiveX to access DHTML document?

Waldemar Osuch osuchw at ecn.ab.ca
Sat May 8 19:07:08 EDT 2004


"angel" <dai4happy at yahoo.com> wrote in message news:<c7ibmb$24b2$1 at news.f.de.plusline.net>...
> Hi
> 
> I want to write an ActiveX by using python. And I know how do, but I don't
> know how python to access DHTML Document.If using cpp, it can be done by
> following source.
> /****/
> CComPtr<IOleContainer> spContainer;
> m_spClientSite->GetContainer(&spContainer);
> CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spDoc(spContainer);
> if (spDoc)
>     spDoc->put_bgColor(CComBSTR(_T("pink")));
> /****/
> Who can tell me how to do the same in python? Thanx
> 
> ps. I use win32com package.
> 
> Thanx again
> angel

Assuming you want to have HTML Document within IE following should
work from the command line.

>>> from win32com.client import Dispatch
>>> ie = Dispatch("InternetExplorer.Application")
>>> ie.Visible = True
>>> ie.Navigate('about:blank')
>>> doc = ie.Document
>>> doc.bgColor = "pink"

I would also recommend running Tools->COM Makepy utility from Pythowin
on Microsoft Internet Controls (for Internet Explorer)
and Microsoft HTML Object Library (for DHTML Document)

waldek



More information about the Python-list mailing list