def _set_treeview_content(self, content): """Sets TreeView content.""" # clear TextView content for column in self.treeview.get_columns(): self.treeview.remove_column(column) cell = gtk.CellRendererText() cell.set_property("font-desc", pango.FontDescription("Nokia Sans 22")) cell.set_property("height", 70) if self.mode == CATEGORIES_MODE: column1 = create_column(_("Categories"), cell, 0, cell_func=cell_capitalizer) self.treeview.append_column(column1) else: column1 = create_column(_("Product"), cell, 0, cell_func=cell_capitalizer) column2 = create_column(_("Carbohydrates"), cell, 1, cell_func=cell_float_to_str) column3 = create_column(_("Index"), cell, 2, cell_func=cell_float_to_str) # temporary hide Index column column3.set_visible(False) column4 = create_column(_("Category"), cell, 4, cell_func=cell_capitalizer) for column in (column1, column2, column3, column4): self.treeview.append_column(column) self.treeview.set_model(content) # sorting content in the first column content.set_sort_column_id(0, gtk.SORT_ASCENDING)
def _set_treeview_content(self, content): """Sets TreeView content.""" # clear TextView content for column in self.treeview.get_columns(): self.treeview.remove_column(column) cell = gtk.CellRendererText() cell.set_property('font-desc', pango.FontDescription( \ 'Nokia Sans 22')) cell.set_property('height', 70) if self.mode == COMPOSITIONS_MODE: # content (str, float, int, float, int) # compname, carbohydrates, chunks, carbohydrates per chunk, compid column1 = create_column(_('Composition'), cell, 0, \ cell_func=cell_capitalizer) column2 = create_column(_('Bread unit'), cell, 1, \ cell_func=cell_float_to_str) column3 = create_column(_('Chunks'), cell, 2) column4 = create_column(_('Bread unit per chunk'), cell, 3, \ cell_func=cell_float_to_str) for column in (column1, column2, column3, column4): self.treeview.append_column(column) else: # content (str, int, int) # productname, productweight, productid column1 = create_column(_('Product'), cell, 0, \ cell_func=cell_capitalizer) column2 = create_column(_('Weight'), cell, 1) for column in (column1, column2): self.treeview.append_column(column) self.treeview.set_model(content) content.set_sort_column_id(0, gtk.SORT_ASCENDING)