Home > Blockchain >  Reading data from GUI table in Python
Reading data from GUI table in Python

Time:10-28

I am trying to design a simple GUI via tkinter.
I've inserted a 2D table where I can feed the data and now I would like to access the entered data in order to use them further in the program.
Can someone please help me with that? In the following image you can see the table I'm working with:

enter image description here

And here you can look at the code I'm using to make this table looks like this:

 
    height=5
    width=2
    for i in range(height):
        for j in range(width):
            b=Entry(window, textvariable=Intvar()
            b.grid(row=i 1, column=j)

CodePudding user response:

You can use a 2D list to store the IntVar used for those Entry widgets:

height=5
width=2
varlist = [[IntVar() for _ in range(width)] for _ in range(height)]
for i in range(height):
    for j in range(width):
        b=Entry(window, textvariable=varlist[i][j])
        b.grid(row=i 1, column=j)

Then later you can use varlist[i][j].get() to get the value for required entry.

  • Related