def make_view(self, columns):
self._view = gtk.TreeView(self._store)
for _type, _col in columns:
if _col.startswith("__"):
continue
index = columns.index((_type, _col))
if _type == gobject.TYPE_STRING or \
_type == gobject.TYPE_INT or \
_type == gobject.TYPE_FLOAT:
rend = gtk.CellRendererText()
column = gtk.TreeViewColumn(_col, rend, text=index)
column.set_resizable(True)
rend.set_property("ellipsize", pango.ELLIPSIZE_END)
elif _type == gobject.TYPE_BOOLEAN:
rend = gtk.CellRendererToggle()
rend.connect("toggled", self._toggle, index)
column = gtk.TreeViewColumn(_col, rend, active=index)
else:
raise Exception("Unknown column type (%i)" % index)
column.set_sort_column_id(index)
self._view.append_column(column)
self._view.connect("button_press_event", self.mouse_cb)
评论列表
文章目录