parameters: (self, iter_insert, table=None, table_justification=None, text_buffer=None)
docstring: Insert a Table at the Given Iter
docstring_summary: Insert a Table at the Given Iter
docstring_tokens: Insert a Table at the Given Iter
function: def table_insert(self, iter_insert, table=None, table_justification=None, text_buffer=None):
          """Insert a Table at the Given Iter"""
          if not text_buffer: text_buffer = self.dad.curr_buffer
          if table != None:
              self.dad.table_columns = len(table['matrix'][0])
              self.dad.table_rows = len(table['matrix']) - 1
              headers = table['matrix'][-1]
              table_col_min = table['col_min']
              table_col_max = table['col_max']
          else:
              headers = [_("click me")]*self.dad.table_columns
              table_col_min = self.dad.table_col_min
              table_col_max = self.dad.table_col_max
          anchor = text_buffer.create_child_anchor(iter_insert)
          anchor.liststore = gtk.ListStore(*(str,)*self.dad.table_columns)
          anchor.treeview = gtk.TreeView(anchor.liststore)
          anchor.renderers_text = []
          for element in range(self.dad.table_columns):
              label = gtk.Label('<b>' + headers[element] + '</b>')
              label.set_use_markup(True)
              label.set_tooltip_text(_("Click to Edit the Column Settings"))
              label.show()
              renderer_text = gtk.CellRendererText()
              renderer_text.set_property('editable', True)
              renderer_text.set_property('wrap-width', table_col_max)
              renderer_text.set_property('wrap-mode', pango.WRAP_WORD_CHAR)
              renderer_text.set_property('font-desc', pango.FontDescription(self.dad.pt_font))
              renderer_text.connect('edited', self.on_table_cell_edited, anchor.liststore, element)
              renderer_text.connect('editing-started', self.on_table_cell_editing_started, anchor.liststore, element)
              column = gtk.TreeViewColumn("", renderer_text, text=element)
              column.set_min_width(table_col_min)
              column.set_clickable(True)
              column.set_widget(label)
              column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
              column.connect('clicked', self.table_column_clicked, anchor, element)
              anchor.treeview.append_column(column)
              anchor.renderers_text.append(renderer_text)
          anchor.headers = headers
          anchor.table_col_min = table_col_min
          anchor.table_col_max = table_col_max
          anchor.treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
          anchor.treeview.connect('button-press-event', self.on_mouse_button_clicked_treeview_table, anchor)
          anchor.treeview.connect('key_press_event', self.on_key_press_treeview_table, anchor)
          anchor.frame = gtk.Frame()
          anchor.frame.add(anchor.treeview)
          anchor.frame.set_shadow_type(gtk.SHADOW_NONE)
          anchor.eventbox = gtk.EventBox()
          anchor.eventbox.add(anchor.frame)
          self.dad.sourceview.add_child_at_anchor(anchor.eventbox, anchor)
          anchor.eventbox.show_all()
          for row in range(self.dad.table_rows):
              row_iter = anchor.liststore.append([""]*self.dad.table_columns)
              if table != None:
                  for column in range(self.dad.table_columns):
                      try: anchor.liststore[row_iter][column] = table['matrix'][row][column]
                      except: pass # there are cases when some rows have less columns
          if table_justification:
              text_iter = text_buffer.get_iter_at_child_anchor(anchor)
              self.dad.state_machine.apply_object_justification(text_iter, table_justification, text_buffer)
          elif self.dad.user_active:
              # if I apply a justification, the state is already updated
              self.dad.state_machine.update_state()
function_tokens: def table_insert ( self , iter_insert , table = None , table_justification = None , text_buffer = None ) : if not text_buffer : text_buffer = self . dad . curr_buffer if table != None : self . dad . table_columns = len ( table [ 'matrix' ] [ 0 ] ) self . dad . table_rows = len ( table [ 'matrix' ] ) - 1 headers = table [ 'matrix' ] [ - 1 ] table_col_min = table [ 'col_min' ] table_col_max = table [ 'col_max' ] else : headers = [ _ ( "click me" ) ] * self . dad . table_columns table_col_min = self . dad . table_col_min table_col_max = self . dad . table_col_max anchor = text_buffer . create_child_anchor ( iter_insert ) anchor . liststore = gtk . ListStore ( * ( str , ) * self . dad . table_columns ) anchor . treeview = gtk . TreeView ( anchor . liststore ) anchor . renderers_text = [ ] for element in range ( self . dad . table_columns ) : label = gtk . Label ( '<b>' + headers [ element ] + '</b>' ) label . set_use_markup ( True ) label . set_tooltip_text ( _ ( "Click to Edit the Column Settings" ) ) label . show ( ) renderer_text = gtk . CellRendererText ( ) renderer_text . set_property ( 'editable' , True ) renderer_text . set_property ( 'wrap-width' , table_col_max ) renderer_text . set_property ( 'wrap-mode' , pango . WRAP_WORD_CHAR ) renderer_text . set_property ( 'font-desc' , pango . FontDescription ( self . dad . pt_font ) ) renderer_text . connect ( 'edited' , self . on_table_cell_edited , anchor . liststore , element ) renderer_text . connect ( 'editing-started' , self . on_table_cell_editing_started , anchor . liststore , element ) column = gtk . TreeViewColumn ( "" , renderer_text , text = element ) column . set_min_width ( table_col_min ) column . set_clickable ( True ) column . set_widget ( label ) column . set_sizing ( gtk . TREE_VIEW_COLUMN_AUTOSIZE ) column . connect ( 'clicked' , self . table_column_clicked , anchor , element ) anchor . treeview . append_column ( column ) anchor . renderers_text . append ( renderer_text ) anchor . headers = headers anchor . table_col_min = table_col_min anchor . table_col_max = table_col_max anchor . treeview . set_grid_lines ( gtk . TREE_VIEW_GRID_LINES_BOTH ) anchor . treeview . connect ( 'button-press-event' , self . on_mouse_button_clicked_treeview_table , anchor ) anchor . treeview . connect ( 'key_press_event' , self . on_key_press_treeview_table , anchor ) anchor . frame = gtk . Frame ( ) anchor . frame . add ( anchor . treeview ) anchor . frame . set_shadow_type ( gtk . SHADOW_NONE ) anchor . eventbox = gtk . EventBox ( ) anchor . eventbox . add ( anchor . frame ) self . dad . sourceview . add_child_at_anchor ( anchor . eventbox , anchor ) anchor . eventbox . show_all ( ) for row in range ( self . dad . table_rows ) : row_iter = anchor . liststore . append ( [ "" ] * self . dad . table_columns ) if table != None : for column in range ( self . dad . table_columns ) : try : anchor . liststore [ row_iter ] [ column ] = table [ 'matrix' ] [ row ] [ column ] except : pass # there are cases when some rows have less columns if table_justification : text_iter = text_buffer . get_iter_at_child_anchor ( anchor ) self . dad . state_machine . apply_object_justification ( text_iter , table_justification , text_buffer ) elif self . dad . user_active : # if I apply a justification, the state is already updated self . dad . state_machine . update_state ( )