maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Disabling expanding of first item in TouchSelector (python) (https://talk.maemo.org/showthread.php?t=63593)

laasonen 2010-10-10 00:31

Disabling expanding of first item in TouchSelector (python)
 
I'm trying create list with hildon.TouchSelector, but I don't understand how to disable expanding of first item.

It looks like:
http://hosted.laasonen.net/Screensho...010-032002.png
I would like it look like this:
http://hosted.laasonen.net/Screensho...010-032643.png

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 2010-10-10 04:16

Re: Disabling expanding of first item in TouchSelector (python)
 
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()


mikaelh 2010-10-10 07:05

Re: Disabling expanding of first item in TouchSelector (python)
 
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 2010-10-10 14:38

Re: Disabling expanding of first item in TouchSelector (python)
 
Quote:

Originally Posted by mikaelh (Post 837516)
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:
http://hosted.laasonen.net/Screensho...010-032643.png

laasonen 2010-10-12 19:39

Re: Disabling expanding of first item in TouchSelector (python)
 
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?

Slocan 2010-10-15 05:29

Re: Disabling expanding of first item in TouchSelector (python)
 
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)



All times are GMT. The time now is 11:57.

vBulletin® Version 3.8.8