How to load a grid into tkinter from file

I am making a program similar to the memory game where i load a file and put it on a grid in tkinter.

I am currently having problems with this part of my code:

with open("Words.txt","r") as tenWordFile:
    for count in range(10):
        tenWordLine = tenWordFile.readline()
        tenWordLine = tenWordLine.strip("\n")
        Line = tenWordLine.split("\t")
        for r in range (3):
            for c in range (3):
                gridLabel = Label(app, text = Words (r,c),borderwidth = 1 ).grid(row=r,column=c)

When i run my program i get an error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "E:\python\lib\tkinter\", line 1487, in __call__
    return self.func(*args)
  File "E:\computer science\Controlled assessment 2\new", line 33, in tenWordGame
gridLabel = Label(app, text = Words (r,c),borderwidth = 1 ).grid(row=r,column=c)
TypeError: 'list' object is not callable

I am looking for a solution to print out a 3x3 grid with random words from my words file.

Additionally, i am looking for a more pythonic way to this code aswell.

Lastly, thanks for reading and attempting to help me.


Words is a list. You can't call it like function using (). You have to use [] - Words[some_index] or Words[some_index][other_index] if it is two-dimensional list.


BTW: gridLabel = Label(...).grid(...) will assigns None to gridLabel because grid(...) always returns None.

If you don't need gridLabel in other part of code you can skip gridLabel =


If you need gridLabel then do

gridLabel = Label(...)

Need Your Help

How to make CSS for HTML5 <header> work properly in IE?

css internet-explorer css-float

I'm working with a website and everything looks good except the one issue with the #nav-wrapper. In IE it's all the way to the right. That said, it's floated right but floated right of the #nav-wra...

Service worker making extra call

offline service-worker progressive-web-apps

I'm trying to work with service workers for caching and running into an issue with authenticated calls. I'm currently using (https://raw.