def sample_test():
    from tkinter import Tk, Scrollbar, N, S, W, E, ttk
    import numpy

    def test_cmd(event):
        if event.i == 0:
            return arr[event.r, event.c]
        else:
            arr[event.r, event.c] = event.S
            return 'set'

    def browsecmd(event):
        print("event:", event.__dict__)
        print("curselection:", test.curselection())
        print("active cell index:", test.index('active'))
        activeRow = int(test.index('active', 'row'))
        activeCol = int(test.index('active', 'col'))
        print("active:", activeRow)
        print("anchor:", test.index('anchor', 'row'))
        # the following line is operational, it shows that it is possible
        # to modiy programmatically the content of a cell.
        # var[test.index('active')] = 'toto'

    def comboValueChanged(event):
        combobox = event.widget
        print('Selected value in combobox: '+combobox.get())

    root = Tk()
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)

    numrows, numcols = 6250,40

    #Using ArrayVar consumes double as much memory as NumPy+command 
    #var = ArrayVar(root)
    #for y in range(0, numrows):
    #    for x in range(0, numcols):
    #        index = "%i,%i" % (y, x)
    #        var[index] = index
    arr = numpy.empty((numrows+2, numcols), dtype=object)
    for y in range(numrows):
        for x in range(numcols):
            arr[y, x] = "%i,%i" % (y, x)

    test = Table(root,
                 rows=numrows,
                 cols=numcols,
                 state='normal',
                 width=6,
                 height=6,
                 titlerows=2,
                 titlecols=2,
                 roworigin=0,
                 colorigin=0,
                 selectmode='extended',
                 selecttype='cell',
                 rowstretch='last',
                 colstretch='last',
                 rowheight=-26,
                 colwidth=15,
                 browsecmd=browsecmd,
                 flashmode='off',
                 anchor='e',
                 #variable=var,
                 usecommand=1,
                 background='#fffffffff',
                 relief='sunken',
                 command=test_cmd,
                 takefocus=False,
                 rowseparator='\n'
                 # drawmode='slow'
                 )

    # http://effbot.org/zone/tkinter-scrollbar-patterns.htm
    verticalScrollbar = Scrollbar(root, orient='vertical', command=test.yview_scroll)
    horizontalScrollbar = Scrollbar(root, orient='horizontal', command=test.xview_scroll)
    test.config(xscrollcommand=horizontalScrollbar.set, yscrollcommand=verticalScrollbar.set)
    verticalScrollbar.grid(column="1", row='0', sticky=(N, S))
    horizontalScrollbar.grid(column="0", row='1', sticky=(W, E))

    kwargs = {'4,5': '5,3', '0,0': '0,1'}
    test.spans(index=None, **kwargs)
    for y in range(2, numrows):
        for x in range(2, numcols):
            if (x%2==0 and y%2==1) or (x%2==1 and y%2==0):
                index = "%i,%i" % (y, x)
                test.tag_cell('disabled', index)
    for x in range(2, numcols):
        index = "%i,%i" % (0, x)
        test.tag_cell('border', index)
        index = "%i,%i" % (1, x)
        test.tag_cell('border', index)
    for y in range(1, numrows):
        index = "%i,%i" % (y, 0)
        test.tag_cell('border-left-right', index)
        index = "%i,%i" % (y, 1)
        test.tag_cell('border', index)
    
    for y in range(2, numrows):
        cities = ('Brussels', 'Luxembourg', 'Strasbourg', 'Trier', 'Rome')
        combobox = ttk.Combobox(test, values=cities, state='readonly')
        test.window_configure('%i,9'%y, window=combobox, sticky=(N, E, S, W))
        combobox.bind(sequence='<<ComboboxSelected>>',
                      func=comboValueChanged,
                      add='+')

    def cellRight(event, *args):
        widget = event.widget
        titleRows = int(widget.cget('titlerows'))
        titleCols = int(widget.cget('titlecols'))
        top = int(widget.cget('roworigin'))+titleRows
        left = int(widget.cget('colorigin'))+titleCols
        try:
            col = int(widget.index('active', 'col'))
            row = int(widget.index('active', 'row'))
        except (tkinter.TclError):
            row, col = top-1, left
        maxRows = int(widget.cget('rows'))
        maxCols = int(widget.cget('cols'))

        widget.selection_clear('all')
        if row<top:
            if (col<left):
                index = '%i,%i'% (top, left)
            else:
                index = '%i,%i'% (top, col)
            widget.activate(index)
            widget.see(index)
            widget.selection_set(index)
        elif col<left:
            index = '%i,%i'% (row, left)
            widget.activate(index)
            widget.see(index)
            widget.selection_set(index)
        elif col<maxCols-titleCols-1:
            widget.moveCell(0, 1)
        elif row<maxRows-titleCols-1:
            widget.moveCell(1, left-col)
        else:
            widget.moveCell(top-row, left-col)

    def cellDown(event, *args):
        widget = event.widget
        titleRows = int(widget.cget('titlerows'))
        titleCols = int(widget.cget('titlecols'))
        top = int(widget.cget('roworigin'))+titleRows
        left = int(widget.cget('colorigin'))+titleCols
        try:
            col = int(widget.index('active', 'col'))
            row = int(widget.index('active', 'row'))
        except (tkinter.TclError):
            row, col = top-1, left
        maxRows = int(widget.cget('rows'))
        maxCols = int(widget.cget('cols'))

        widget.selection_clear('all')
        if row<top:
            if (col<left):
                index = '%i,%i'% (top, left)
            else:
                index = '%i,%i'% (top, col)
            widget.activate(index)
            widget.see(index)
            widget.selection_set(index)
        elif col<left:
            index = '%i,%i'% (row, left)
            widget.activate(index)
            widget.see(index)
            widget.selection_set(index)
        elif row<maxRows-titleRows-1:
            widget.moveCell(1, 0)
        elif col<maxCols-titleCols-1:
            widget.moveCell(top-row, 1)
        else:
            widget.moveCell(top-row, left-col)
        return 'break' # do not insert return in cell content

    menu = test.contextMenu()
    menu.add_command(label="Quit", underline=0, command=root.destroy)
    test.bind("<Tab>", func=cellRight, add="+")
    test.bind("<Return>", func=cellDown)
    test.tag_cell('border-left-top', "-2,-2")
    test.tag_raise('border-left-top', abovethis='title')
    test.tag_raise('border-left-right', abovethis='title')
    test.tag_raise('border', abovethis='title')
    test.grid(column="0", row='0', sticky=(N, W, S, E))
    test.tag_configure('sel', background = '#000400400')
    test.tag_configure('active', background = '#000a00a00')
    test.tag_configure('title', anchor='w', bg='#d00d00d00', fg='#000000000', relief='flat')
    test.tag_configure('disabled', bg='#d00d00d00', fg='#000000000', relief='flat', state='disabled')
    test.tag_configure('border-left-top', relief='ridge', borderwidth=(1,0,1,0))
    test.tag_configure('border-left-right', relief='ridge', borderwidth=(1,1,0,0))
    test.tag_configure('border', relief='ridge', borderwidth=(1,1,1,1))

    data = ('py','t','h','o','n','','+','','Tk','')

    def add_new_data(*args):
        #test.config(state='normal')
        test.insert_rows('end', 1)
        r = test.index('end').split(',')[0] #get row number <str>
        args = (r,) + args
        idx = r + ',1'
        test.set('row', idx, *args)
        test.see(idx)
        #test.config(state='disabled')

    root.after(3000, add_new_data, *data)
    root.after(4000, add_new_data, *data)
    root.mainloop()
dataset/ETHPy150Open Arelle/Arelle/arelle/TkTableWrapper.py/sample_test/original