def initialize(self, definition_lod=None, attributes_lod=None): ''' Initializes a treeview as table or tree. The definition_lod will be merged with the attributes_lod, thus the attributes_lod can be already contained in the definition_lod if desired! definition_lod = [{'column_name': 'id', 'column_label': 'Primärschlüssel', 'visible': True, 'editable': True, 'sortable': True, 'resizeable': True, 'reorderable': True, 'width': 175, 'dateformat': '%d.%m.%Y}] attributes_lod = [{'column_name': 'id' 'data_type': 'bigint' => #image makes a pixbuf column => #combobox makes a combobox column => #progressbar makes a progressbar column 'character_maximum_length': = 20 'numeric_precision' = 2 'numeric_scale' = ? 'is_nullable' = True}]''' self.definition_lod = definition_lod # Merge definition_lod and attributes_lod together. self.definition_lod = merge_two_lods(self.definition_lod, attributes_lod, 'column_name') # First off, the columns has to be sorted in given order. try: self.definition_lod.sort(compare_by('column_number')) except: raise # Before anything else happens on the treeview, clear it. self.clear() # Make image list to populate them later! self.image_list = wx.ImageList(16, 16) self.ID_LEFT = self.image_list.Add(IconSet16.getleft_16Bitmap()) self.ID_UP = self.image_list.Add(IconSet16.getup_16Bitmap()) self.ID_DOWN = self.image_list.Add(IconSet16.getdown_16Bitmap()) self.SetImageList(self.image_list) column_number = 0 for column_dict in self.definition_lod: column_label = column_dict.get('column_label') if column_label == None: column_label = column_dict.get('column_name') visible = column_dict.get('visible') if visible <> False: visible = True self.AddColumn(text=column_label) column_dict['column_number'] = column_number else: continue sortable = column_dict.get('sortable') if sortable <> False: self.SetColumnImage(column=column_number, image=self.ID_LEFT) width = column_dict.get('width') if width <> None: self.SetColumnWidth(column_number, width) column_number += 1 self.number_of_columns = column_number