Active Topics

 


Reply
Thread Tools
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#1
I'm trying create list with hildon.TouchSelector, but I don't understand how to disable expanding of first item.

It looks like:

I would like it look like this:


Code:
Code:
#Librarys
import gtk, hildon

#Create window
win = hildon.StackableWindow()
win.connect("destroy", gtk.main_quit, None)

#Create list
selector = hildon.TouchSelector()
store = gtk.ListStore(gtk.gdk.Pixbuf, str)
for word in "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vestibulum sem quis sapien lobortis fermentum.".split(" "):
	store.append([ gtk.gdk.pixbuf_new_from_file("icon.png"), "<span font_desc=\"Nokia Sans 18\" foreground=\"#ffffffffffff\">"+word+"</span>\n<span font_desc=\"Nokia Sans 13\" foreground=\"#babababababa\">Descrption</span>"])

#Image
renderer = gtk.CellRendererPixbuf()
#FIXME: disable expanding
column = selector.append_column(store, renderer)
column.add_attribute(renderer, "pixbuf", 0)

#Text
renderer = gtk.CellRendererText()
column.pack_start(renderer, True)
column.add_attribute(renderer, "markup", 1)
column.set_property("text-column", 1)
print column

#Add to window.
win.add(selector)
win.show_all()
gtk.main()
Thanks.
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#2
Or is there a way to get hildon_live_search work with python to get my treeview-version work?
Code:
#Librarys
import gtk, hildon

#Create window
win = hildon.StackableWindow()
win.connect("destroy", gtk.main_quit, None)
parea = hildon.PannableArea()

#Create list
store = gtk.ListStore(gtk.gdk.Pixbuf, str)
for word in "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vestibulum sem quis sapien lobortis fermentum.".split(" "):
	store.append([ gtk.gdk.pixbuf_new_from_file("icon.png"), "<span font_desc=\"Nokia Sans 18\" foreground=\"#ffffffffffff\">"+word+"</span>\n<span font_desc=\"Nokia Sans 13\" foreground=\"#babababababa\">Descrption</span>"])
treeview = gtk.TreeView(store)

#Image
renderer = gtk.CellRendererPixbuf()
column = gtk.TreeViewColumn()
column.pack_start(renderer, False)
column.add_attribute(renderer, "pixbuf", 0)
column.set_min_width(40)
treeview.append_column(column)

#Text
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn('title', renderer, markup=1)
column.set_property("expand", True)
treeview.append_column(column)


#FIXME: Searching doesn't work at all..
treeview.set_search_column(1)
treeview.set_enable_search(True)

#Add to window.
parea.add(treeview)
win.add(parea)
win.show_all()
gtk.main()

Last edited by laasonen; 2010-10-10 at 04:18.
 
Posts: 79 | Thanked: 20 times | Joined on Apr 2010
#3
Cannot exactly help you here. I have just put buttons within a PannableArea to get to what you described as your desired end result. Not fancy in the model-view sense, but more control.
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#4
Originally Posted by mikaelh View Post
Cannot exactly help you here. I have just put buttons within a PannableArea to get to what you described as your desired end result. Not fancy in the model-view sense, but more control.
My TreeView+PannableArea-version looks like what I would like it to look, but it doesn't have search capabilityes:
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#5
I tryed this:
Code:
#Image
renderer = gtk.CellRendererPixbuf()
column = selector.append_column(store, renderer)
column.add_attribute(renderer, "pixbuf", 0)
column.set_property("expand", False)
But it only gives this error:
Code:
TypeError: object of type `HildonTouchSelectorColumn' does not have property `expand'
Any ideas?
 
Posts: 324 | Thanked: 371 times | Joined on Dec 2009 @ Vancouver, BC
#6
You need to use the GtkCellLayout functions of the column to add the cell renderer with expand=False, like you did for the 2nd renderer.
I think the doc says that the 2nd argument in append_column should be None, but it's giving an error, so I add the renderer, and then clear() it. Alternatively, you can probably add the text renderer first, and then reorder them.

Code:
column = selector.append_column(store, renderer) 
column.clear()
column.pack_start(renderer, expand=False)
column.add_attribute(renderer, "pixbuf", 0)

#Text
renderer = gtk.CellRendererText()
column.pack_start(renderer, True)
column.add_attribute(renderer, "markup", 1)
column.set_property("text-column", 1)
 

The Following User Says Thank You to Slocan For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 17:07.