0

I am new to Tkinter. I have tried a few widgets provided by Tkinter but cannot find a suitable way to display a dataframe.

I tried Tkinter.Text. I used update() instead of mainloop() because I would like to update df and display again. mainloop() will block my program. The problem with this approach is that when the df gets big in size, it cannot be displayed fully.

import pandas
import numpy as np
import Tkinter

root = Tkinter.Tk() 
t1 = Tkinter.Text(root) 
t1.pack()
df = pandas.DataFrame(np.random.randn(900,2),columns=list('AB')) 
t1.insert('end', df) 

root.update()

I also tried Tkinter.Lablel. It actually insert entries of the df one by one, which is very slow.

from Tkinter import *
for i in range(900):
    for j in range(4):
        l = Label(text='%d.%d' % (i, j), relief=RIDGE)
        l.grid(row=i, column=j, sticky=NSEW)
mainloop()

So what is the easiest way to display a data frame(no need for editing)? To be specific, it should more or less look like an excel spread sheet with scrollbars, and allow the displayed df to be updated and display again. Also, it should not take too long if df has hundreds of rows.

Thank you.

Pollyanna
  • 11
  • 1
  • 1
  • 5
  • 1
    Welcome to SO. Although your question sounds ok, I'd recommend to summarize your needs in the question in the bottom (the word "nicely" is too vague). Best regards. – YakovL Jul 18 '16 at 11:36
  • @YakovL thanks for the advice. I added my needs at the end of the question. – Pollyanna Jul 18 '16 at 14:28
  • Looks like [this](https://github.com/dmnfarrell/pandastable) does exactly what you want. – chthonicdaemon Jul 18 '16 at 14:53

1 Answers1

0

I found pandas-qt easy to use and the display is very fast.

There are some alternative solutions here

Community
  • 1
  • 1
Pollyanna
  • 11
  • 1
  • 1
  • 5