[Tutor] Tkinter layout question

Phil phil_lor at bigpond.com
Fri Apr 21 21:51:03 EDT 2017


On Thu, 20 Apr 2017 13:43:07 +0100
Alan Gauld via Tutor <tutor at python.org> wrote:

> If still confused drop a question here.

Maybe not totally confused, more a question of best practice.

Using your example table class, I commented out all from, and including, "if __name__ == "__main__":" down and saved the file as table_class.py. I then created test.py as follows:

from table_class import *

top = tk.Tk()

tab = DisplayTable(top,
                    ["Left","middle","Right"],
                    [[1,2,1],
                    [3,4,3],
                    [5,6,5]],
                    datacolor='blue',
                    cellcolor='yellow',
                    gridcolor='red',
                    hdcolor='black')

tab.pack()

Two questions:
I can see where tk comes from but I'm unsure of the origin of Tk() other than a reference to tkinter.
Have I used you table class correctly? It works, of course, but it doesn't look correct.

-- 
Regards,
Phil


More information about the Tutor mailing list