<commit_before>import datetime
import random
import time

import gtk

from kiwi.datatypes import currency
from kiwi.ui.widgets.list import (Column, List, SequentialColumn,
                                  ColoredColumn, SummaryLabel)

def random_date():
    max = datetime.datetime.today()
    min = max.replace(year=max.year-5)

    timestamp = random.randint(
        time.mktime(min.timetuple()),
        time.mktime(max.timetuple()))
    return datetime.datetime.fromtimestamp(timestamp)

class Person:
    """The parameters need to be of the same name of the column headers"""
    def __init__(self, name, age, city):
        (self.name, self.age,
         self.city) = name, age, city
        self.date = self.datetime = self.time = random_date()
        self.extra = -1
        self.worth = random.randint(0, 10000) / 100.0
        self.bool = random.randint(0, 1) and True or False

    def __repr__(self):
        return '<Person %s>' % self._name

class MyColumn(Column):
    pass

def format_func(age):
    if age % 2 == 0:
        return float(age)
    return age

def color(data):
    return data % 2 == 0

columns = [
    SequentialColumn(),
    MyColumn('name', tooltip='What about a stupid tooltip?', editable=True, expand=True),
    Column('age', data_type=int, format_func=format_func, editable=True,
           width=40),
    Column('bool', data_type=bool, editable=True, width=40),
    Column('worth', data_type=currency, editable=True),
    Column('city', visible=True, sorted=True, expand=True),
    Column('date', data_type=datetime.date),
    Column('time', data_type=datetime.time),
    Column('datetime', data_type=datetime.datetime),
    ColoredColumn('age', data_type=int, color='red', data_func=color),
    ]

data = (Person('Evandro', 23, '<NAME>'),
        Person('Daniel', 22, '<NAME>'),
        Person('Henrique', 21, '<NAME>'),
        Person('Gustavo', 23, 'San Jose do Santos'),
        Person('Johan', 23, 'Goteborg'),
        Person('Lorenzo', 26, 'Granada')
       )

win = gtk.Window()
win.set_size_request(650, 300)
win.connect('destroy', gtk.main_quit)

vbox = gtk.VBox()
win.add(vbox)

l = List(columns, mode=gtk.SELECTION_MULTIPLE)
l.extend(data)
l.append(Person('Nando', 29+len(l), 'Santos'))


# add an extra person

vbox.pack_start(l)

label = SummaryLabel(klist=l, column='age', label='<b>Total:</b>',<commit_msg>utf-8, salary, no expand<commit_after># encoding: utf-8
import datetime
import random
import time

import gtk

from kiwi.datatypes import currency
from kiwi.ui.widgets.list import (Column, List, SequentialColumn,
                                  ColoredColumn, SummaryLabel)

def random_date():
    max = datetime.datetime.today()
    min = max.replace(year=max.year-5)

    timestamp = random.randint(
        time.mktime(min.timetuple()),
        time.mktime(max.timetuple()))
    return datetime.datetime.fromtimestamp(timestamp)

class Person:
    """The parameters need to be of the same name of the column headers"""
    def __init__(self, name, age, city):
        (self.name, self.age,
         self.city) = name, age, city
        self.date = self.datetime = self.time = random_date()
        self.extra = -1
        self.salary = random.randint(40, 180) * 10
        self.bool = random.randint(0, 1) and True or False

    def __repr__(self):
        return '<Person %s>' % self._name

class MyColumn(Column):
    pass

def format_func(age):
    if age % 2 == 0:
        return float(age)
    return age

def color(data):
    return data % 2 == 0

columns = [
    SequentialColumn(),
    MyColumn('name', tooltip='What about a stupid tooltip?', editable=True),
    Column('age', data_type=int, format_func=format_func, editable=True,
           width=40),
    Column('bool', data_type=bool, editable=True, width=40),
    Column('salary', data_type=currency, editable=True),
    Column('city', visible=True, sorted=True),
    Column('date', data_type=datetime.date),
    Column('time', data_type=datetime.time),
    Column('datetime', data_type=datetime.datetime),
    ColoredColumn('age', data_type=int, color='red', data_func=color),
    ]

data = (Person('Evandro', 23, '<NAME>'),
        Person('Daniel', 22, 'São Carlos'),
        Person('Henrique', 21, 'São Carlos'),
        Person('Gustavo', 23, 'São Jose do Santos'),
        Person('Johan', 23, 'Göteborg'),
        Person('Lorenzo', 26, 'Granada')
       )

win = gtk.Window()
win.set_size_request(650, 300)
win.connect('destroy', gtk.main_quit)

vbox = gtk.VBox()
win.add(vbox)

l = List(columns, mode=gtk.SELECTION_MULTIPLE)
l.extend(data)
l.append(Person('Nando', 29+len(l), 'Santos'))


# add an extra person

vbox.pack_start(l)

label = SummaryLabel(klist=l, column='age', label='<b>Total:</b>',
{'fraction_non_alphanumeric': 0.14937671667018804, 'fraction_numerical': 0.017536446228607647, 'mean_word_length': 3.4201680672268906, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4304832', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1554, 'n_words': 371}