<commit_before>#!/usr/bin/env python

import gtk
from taburet.ui.grid import GridColumn, Grid, IntGridColumn
from taburet.ui import idle

model = [{'aaa': r, 'bbb': 'wow'} for r in range(50)]
model.append({'aaa':'', 'bbb':''})

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
window.set_position(gtk.WIN_POS_CENTER)
window.set_default_size(100, 400)

sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
window.add(sw)

table = Grid(IntGridColumn('aaa'), GridColumn('bbb'))
sw.add(table)
table.set_model(model)
table.show()

w, h = sw.size_request()
window.set_default_size(w, min(max(400, h), 500))
window.show_all()

window.connect('delete-event', lambda *args:gtk.main_quit())

gtk.main()<commit_msg>modify test according to grid api changes<commit_after>#!/usr/bin/env python

import gtk
from taburet.ui.grid import GridColumn, Grid, IntGridColumn, DirtyRow

from taburet.ui.util import idle

def on_commit(dr, row):
    if 'isnew' in row:
        dr.grid.model.append({'aaa':'', 'bbb':'', 'isnew':True})
        del row['isnew']
        idle(dr.grid.populate, dr.grid.from_row+1, False, (dr.model_row+1, 0))

def on_error(dr, e):
    print e

model = [{'aaa': r, 'bbb': 'wow'} for r in range(50)]
model.append({'aaa':'', 'bbb':'', 'isnew':True})

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
window.set_position(gtk.WIN_POS_CENTER)
window.set_default_size(100, 400)

sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
window.add(sw)

table = Grid([IntGridColumn('aaa'), GridColumn('bbb')])
sw.add(table)
dr = DirtyRow(table, on_commit, on_error)
table.set_model(model, dr)
table.show()

w, h = sw.size_request()
window.set_default_size(w, min(max(400, h), 500))
window.show_all()

window.connect('delete-event', lambda *args:gtk.main_quit())

gtk.main()
{'fraction_non_alphanumeric': 0.1711286089238845, 'fraction_numerical': 0.01627296587926509, 'mean_word_length': 5.981684981684982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5538462', 'n_tokens_mistral': 814, 'n_tokens_neox': 761, 'n_words': 142}