author Pierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 13 Jun 2008 15:37:48 +0200
changeset 5 ee38ef554863
parent 0 7710b138d4eb
permissions -rw-r--r--
remove apycot.ini

# Copyright (c) 2004 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
"""this module defines some treeview / treemodels utilities"""

__revision__ = '$Id: trees.py,v 1.6 2004-12-16 09:44:52 syt Exp $'
__metaclass__ = type

import gtk

def init_treeview_columns(treeview, titles,  displayed=None, sort_info=None,
                          keep_existing=False, **kwargs):
    """initalizes all the treeviews columns

    keep_exsiting must be set to True if existing columns must not be removed
    sort_info is an optional list where the element with index <n> is the
    column_id used to sort column <n>.
    If column_id equals 0, gtk will use its default (trivial) sort function.
    if not keep_existing:
        for column in treeview.get_columns():
    for col_index, col_name in enumerate(titles):
        if displayed is not None and col_name not in displayed:
        column = gtk.TreeViewColumn(col_name, gtk.CellRendererText(),
                                    text=col_index, **kwargs)
        if sort_info is not None:
            sort_id = sort_info[col_index]
            if sort_id == 0: