Re: [pyxpcom] python and xulrunner - how to use
by Vanush Vee other posts by this author
May 21 2009 11:29PM messages near this date
view in the new Beta List Site
Re: [pyxpcom] python and xulrunner - how to use
|
Re: [pyxpcom] python and xulrunner - how to use
Hello
Thanks for that clarification.
Now. Another question.. How do I get pywin32 working? I copied over the
files from my python directory and I get the error : No module called
pywin32.
On Fri, May 22, 2009 at 10:33 AM, Todd Whiteman <toddw@[...].com> wrote:
> Vanush Vee wrote:
>
> > Hi
> >
> > I want to use XULRunner with python because it seems like a really good
> > way to make my scripts fancy without bothering with large UI frameworks,
> > however, i'm having some trouble getting it to work. Before, I was unable to
> > get any method of an element working (such as menulist), the console would
> > say 'has no attribute appendItem' but then Todd Whiteman suggested that I
> > have to QueryInterface. Okay, but then I want to use the getRowCount method
> > of listbox , I get a no attribute error no matter what interface I'm
> > querying
> >
> > <listbox id="myList" rows="5" flex="1">
> > </listbox>
> > <button label="getRowCount" oncommand="getRowCount()" />
> >
> > and then in my script
> >
> > def getRowCount():
> > nlist = document.getElementById('myList')
> > nlist.QueryInterface(components.interfaces.nsIListBoxObject)
> > nlist.getRowCount()
> >
> > I just get the error
> >
> > WARNING:xpcom:Python DOM script error
> > Traceback (most recent call last):
> > File "C:\pyxpcom_gui_app\xulrunner\pylib\nsdom\context.py", line 478, in
> > CallEventHandler
> > return handler(*args)
> > File "chrome://pyxpcom_gui_app/content/pyxpcom_gui_app.xul", line 1, in
> > oncommand
> > File "chrome://pyxpcom_gui_app/content/pyxpcom_gui_app.xul", line 42, in
> > getRowCount
> > File "C:\pyxpcom_gui_app\xulrunner\pylib\xpcom\client\__init__.py", line
> > 336, in QueryInterface
> > raw_iface = self._comobj_.QueryInterface(iid, 0)
> > <class 'xpcom.Exception'>: -2147467262 (-2147467262)
> >
> >
> > Any ideas as to what is wrong/what I should do. Thx.
> >
>
> You'll need to check against the interfaces, for listbox it's
> nsIDOMXULMultiSelectControlElement:
>
> http://mxr.mozilla.org/seamonkey/source/dom/public/idl/xul/nsIDOMXULMultSelectCntrlEl.idl#
43
>
> which does not seem to define a getRowCount() in it's interface (or any of
> it's parent interfaces).
>
> This is because listbox is implemented in XBL, and as such, provides
> additional methods like "getRowCount" that will only be accessible to
> JavaScript, you can see the listbox implementation at:
> http://mxr.mozilla.org/seamonkey/source/toolkit/content/widgets/listbox.xml
>
> There is an alternative attribute "itemCount" which is defined on the
> parent interface (nsIDOMXULSelectControlElement), which seems to do the same
> thing, so you could use:
> nlist.itemCount
>
> Cheers,
> Todd
>
Thread:
Vanush Vee
Todd Whiteman
Vanush Vee
Rasjid Wilcox
Vanush Vee
|