Skip to content

Code Examples

Damien Farrell edited this page Mar 23, 2016 · 4 revisions

Create a parent frame and then add the table to it:

from tkinter import *
from pandastable import Table
#assuming parent is the frame in which you want to place the table
pt = Table(parent)
pt.show()

Update the table:

#alter the DataFrame in some way, then update
pt.redraw()

Import a csv file:

pt.doImport('test.csv')

A class for launching a basic table in a frame:

from tkinter import *
from pandastable import Table, TableModel

class TestApp(Frame):
    """Basic test frame for the table"""
    def __init__(self, parent=None):
        self.parent = parent
        Frame.__init__(self)
        self.main = self.master
        self.main.geometry('600x400+200+100')
        self.main.title('Table app')
        f = Frame(self.main)
        f.pack(fill=BOTH,expand=1)
        df = TableModel.getSampleData()
        self.table = pt = Table(f, dataframe=df,
                                showtoolbar=True, showstatusbar=True)
        pt.show()
        return

app = TestApp()
#launch the app
app.mainloop()
Clone this wiki locally