The Following User Says Thank You to For This Useful Post: | ||
|
2009-10-20
, 05:48
|
Guest |
Posts: n/a |
Thanked: 0 times |
Joined on
|
#2
|
![]() |
2009-10-20
, 09:06
|
Posts: 20 |
Thanked: 71 times |
Joined on Sep 2009
|
#3
|
I've been chatting to tigert in #maemo and he's narrowed it down to Hildon Touch List.. Now we/i/someone just have to find it in the reference manuals..
![]() |
2009-10-20
, 11:18
|
|
Posts: 696 |
Thanked: 1,012 times |
Joined on Mar 2006
@ Asturies, Spain
|
#4
|
import hildon, gobject, gtk class UI: def __init__(self): self.window = hildon.Window() self.window.connect("destroy", gtk.main_quit) parea = hildon.PannableArea() # gtk.HILDON_UI_MODE_NORMAL -> not selection in the treeview # gtk.HILDON_UI_MODE_EDIT -> selection in the treeview treeview = hildon.GtkTreeView(gtk.HILDON_UI_MODE_NORMAL) model = self.create_model() treeview.set_model(model) self.add_columns_to_treeview(treeview) parea.add(treeview) self.window.add(parea) self.window.show_all() def create_model(self): lstore = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING) data = ["Blue color", "Red color"] colors = ["blue.png", "red.png"] iconlist = [] for i in range(len(colors))*10: iconlist.append([data[i], colors[i]]) for item in iconlist: liter = lstore.append() lstore.set(liter, 1, item[0], 0, self.set_pix(item[1])) return lstore def set_pix(self, filename): pixbuf = gtk.gdk.pixbuf_new_from_file(filename) return pixbuf def add_columns_to_treeview(self, treeview): #Column 0 for the treeview renderer = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn() column.pack_start(renderer, True) column.add_attribute(renderer, "pixbuf", 0) treeview.append_column(column) #Column 1 for the treeview renderer = gtk.CellRendererText() column = gtk.TreeViewColumn('title', renderer, text=1) column.set_property("expand", True) treeview.append_column(column) if __name__ == "__main__": UI() gtk.main()
![]() |
2009-10-20
, 11:29
|
|
Posts: 1,391 |
Thanked: 4,272 times |
Joined on Sep 2007
@ Vienna, Austria
|
#5
|
|
2009-10-20
, 17:40
|
Guest |
Posts: n/a |
Thanked: 0 times |
Joined on
|
#6
|
|
2009-10-21
, 01:18
|
Guest |
Posts: n/a |
Thanked: 0 times |
Joined on
|
#7
|
In order to get the correct text style for the secondary text (the font size and the color - see the browser bookmarks screenshot above), you can use functions from this module (in Python; for C, there's hildon-helper.c in the Hildon source code):
http://repo.or.cz/w/gpodder.git?a=bl...rmntl/style.py
An example of how I used this to get the correct style for a ListStore:
http://repo.or.cz/w/gpodder.git?a=bl...frmntl/opml.py
|
2009-10-21
, 03:19
|
Guest |
Posts: n/a |
Thanked: 0 times |
Joined on
|
#8
|
set Gtk.TreeViewColumn('title', renderer, text=1) to Gtk.TreeViewColumn('title', renderer, markup=1)
![]() |
2010-01-08
, 14:20
|
Posts: 120 |
Thanked: 279 times |
Joined on Sep 2009
@ Perth, Australia
|
#9
|
![]() |
2010-02-15
, 09:21
|
Posts: 7 |
Thanked: 0 times |
Joined on May 2008
|
#10
|
A example in Python code:
(code snippet removed, see above)
Put the blue and red squares in the same directory where the script and call them blue.png and red.png (or you can change the script to use your own images and data).
If you want put the images in a HildonTouchSelector, the code is a bit different than in the Treeview from the example. If you need it ask for it ;-)
import hildon, gobject, gtk class UI: def __init__(self): self.window = hildon.Window() self.window.connect("destroy", gtk.main_quit) parea = hildon.PannableArea() # gtk.HILDON_UI_MODE_NORMAL -> not selection in the treeview # gtk.HILDON_UI_MODE_EDIT -> selection in the treeview treeview = hildon.GtkTreeView(gtk.HILDON_UI_MODE_NORMAL) self.add_columns_to_treeview(treeview) model = self.create_model() treeview.set_model(model) parea.add(treeview) self.window.add(parea) self.window.show_all() def create_model(self): lstore = gtk.ListStore(gtk.gdk.Pixbuf, str, str) lstore.append([None, "6. Arie. Buss und Reu\n<small>Andreas Scholl</small>", "3:23"]) lstore.append([self.set_pix("note.png"), "35. Arie. Geduld, Geduld!\n<small>Werner Gura</small>", "2:49"]) return lstore def set_pix(self, filename): pixbuf = gtk.gdk.pixbuf_new_from_file(filename) return pixbuf def add_columns_to_treeview(self, treeview): #Column 0 for the treeview 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) #Column 1 for the treeview renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("title", renderer, markup=1) column.set_property("expand", True) treeview.append_column(column) #Column 2 for the treeview renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("times", renderer, markup=1) treeview.append_column(column) if __name__ == "__main__": UI() gtk.main()
![]() |
Tags |
gtk, list, maemo 5, unknown widgets |
Thread Tools | |
|
So we need to identify:
If we're going to make apps that include lists which arent just a big ladder of hildon buttons, we need to know what this is and how it's done.
Any ideas?
Edit: see also:
and
Last edited by code177; 2009-10-20 at 05:18.