Skip to content

Instantly share code, notes, and snippets.

@gugat
Created May 8, 2017 16:44
Show Gist options
  • Select an option

  • Save gugat/7cf57eb628f3bb0a3d54b3f8d0023b63 to your computer and use it in GitHub Desktop.

Select an option

Save gugat/7cf57eb628f3bb0a3d54b3f8d0023b63 to your computer and use it in GitHub Desktop.
Show Pandas dataframe as table with Tkinter
# Taken from https://github.com/dmnfarrell/pandastable/wiki/Code-Examples
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()
@Petepgp79
Copy link
Copy Markdown

Hi,
This example is good, only have one problem that i can't fix, if you run again the example (by second time) send the next error message :
TclError: invalid command name ".!canvas"
Can someone please help me with this error!!!

@adwiteeymauriya
Copy link
Copy Markdown

Hi,
This example is good, only have one problem that i can't fix, if you run again the example (by second time) send the next error message :
TclError: invalid command name ".!canvas"
Can someone please help me with this error!!!

I am getting the same error. Did anybody figure this out?

@MandavaNavya
Copy link
Copy Markdown

once i load & display the data in the table app Frame , cant able to close the frame again. Kindly let me know how to close

@tjwoodwa
Copy link
Copy Markdown

Also running into this error- anybody figure it out?

@marctemp
Copy link
Copy Markdown

Running python 3.9-dev -- work-around for not being able to close and re-run problem: remove/comment out app.mainloop()

Best guess for why, the mainloop attaches itself to the host so closing the canvas does not kill the process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment