On Wed, Oct 26, 2011 at 10:58:49AM +0100, Tom Medhurst wrote:
> Ok, so almost there, just need to bind the values and actually show
> the data!
> 
> #data
> data=Clutter.ListModel()
> data.set_types([str])
> data.set_names(["Name"])
> data.appendv([0], ["test1"])
> data.appendv([0], ["test2"])
> data.appendv([0], ["test3"])
> #list
> sidebar=Mx.ListView()
> sidebar.set_width(250)
> sidebar.set_model(data)
> sidebar.set_item_type(Mx.Label())
> sidebar.set_factory(SidebarItemFactory())
> #factory
> class SidebarItemFactory(Clutter.Actor, Mx.ItemFactory):
>     def create(self):
>         print "sidebaritemfactory:create"
>         item=Mx.Label()
>         item.set_text("sidebar item")
>         return item
> 
> This shows a blank area where my list view should be, and stdout
> never displays "sidebaritemfactory:create"?
> What I want to achieve is a list which selectable items.. is this
> even the best way to do this? If it is, how can I get it working
> please!

MxListView uses either :item-type (GType) or :factory (MxItemFactory)
to create it's items. If both are given, the item-type will be preferred,
so your SidebarItemFactory won't be used. Apart from this, your
list-view is missing an attribute mapping from model columns to item
properties. In your example,

 sidebar.add_attribute(0, "text")

should do the trick.

> I had to add Clutter.Actor to my Factory as it required it to be a
> derivative of GObject, and I wasn't sure how else to do this?

MxItemFactory is an interface, so your implementation still needs to
derive from a GObject. Using GObject.Object instead of Clutter.Actor
would be enough, but with PyGObject, the name of a vfunc implementation
needs to be prefixed by 'do_'.

so long

:wq buz
-- 
I pretend to work. They pretend to pay me.

GnuPG Fingerprint: 2FFF FC48 C7DF 1EA0 00A0  FD53 8C35 FD2E 6908 7B82

Attachment: signature.asc
Description: Digital signature

_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to