Re: [pyxpcom] python and xulrunner - how to use
by Todd Whiteman other posts by this author
May 21 2009 5:33PM messages near this date
view in the new Beta List Site
[pyxpcom] python and xulrunner - how to use
|
Re: [pyxpcom] python and xulrunner - how to use
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
_______________________________________________
pyxpcom mailing list
pyxpcom@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Vanush Vee
Todd Whiteman
Vanush Vee
Rasjid Wilcox
Vanush Vee
|