def add_columns(tree_view, df_py_dtypes, list_store):
    '''
    Add columns to a `gtk.TreeView` for the types listed in `df_py_dtypes`.

    Args:

        tree_view (gtk.TreeView) : Tree view to append columns to.
        df_py_dtypes (pandas.DataFrame) : Data frame containing type
            information for one or more columns in `list_store`.
        list_store (gtk.ListStore) : Model data.

    Returns:

        None
    '''
    tree_view.set_model(list_store)

    for column_i, (i, dtype_i) in df_py_dtypes[['i', 'dtype']].iterrows():
        tree_column_i = gtk.TreeViewColumn(column_i)
        tree_column_i.set_name(column_i)
        if dtype_i in (int, long):
            property_name = 'text'
            cell_renderer_i = gtk.CellRendererSpin()
        elif dtype_i == float:
            property_name = 'text'
            cell_renderer_i = gtk.CellRendererSpin()
        elif dtype_i in (bool, ):
            property_name = 'active'
            cell_renderer_i = gtk.CellRendererToggle()
        elif dtype_i in (str, ):
            property_name = 'text'
            cell_renderer_i = gtk.CellRendererText()
        else:
            raise ValueError('No cell renderer for dtype: %s' % dtype_i)
        cell_renderer_i.set_data('column_i', i)
        cell_renderer_i.set_data('column', tree_column_i)
        tree_column_i.pack_start(cell_renderer_i, True)
        tree_column_i.add_attribute(cell_renderer_i, property_name, i)
        tree_view.append_column(tree_column_i)
def add_columns ( tree_view , df_py_dtypes , list_store ) : tree_view . set_model ( list_store ) for column_i , ( i , dtype_i ) in df_py_dtypes [ [ 'i' , 'dtype' ] ] . iterrows ( ) : tree_column_i = gtk . TreeViewColumn ( column_i ) tree_column_i . set_name ( column_i ) if dtype_i in ( int , long ) : property_name = 'text' cell_renderer_i = gtk . CellRendererSpin ( ) elif dtype_i == float : property_name = 'text' cell_renderer_i = gtk . CellRendererSpin ( ) elif dtype_i in ( bool , ) : property_name = 'active' cell_renderer_i = gtk . CellRendererToggle ( ) elif dtype_i in ( str , ) : property_name = 'text' cell_renderer_i = gtk . CellRendererText ( ) else : raise ValueError ( 'No cell renderer for dtype: %s' % dtype_i ) cell_renderer_i . set_data ( 'column_i' , i ) cell_renderer_i . set_data ( 'column' , tree_column_i ) tree_column_i . pack_start ( cell_renderer_i , True ) tree_column_i . add_attribute ( cell_renderer_i , property_name , i ) tree_view . append_column ( tree_column_i )
Add columns to a `gtk.TreeView` for the types listed in `df_py_dtypes`.

    Args:

        tree_view (gtk.TreeView) : Tree view to append columns to.
        df_py_dtypes (pandas.DataFrame) : Data frame containing type
            information for one or more columns in `list_store`.
        list_store (gtk.ListStore) : Model data.

    Returns:

        None