This is one my very first python programs, and my very first Tkinter program, so it is just a test.
What I am hoping to accomplish is getting an array (a[]) to store a number from dataA through the variable g at the location a[f].
Then I want to be able to choose which two locations (a[b] and a[c]) that get added up to the variable d, which will be displayed on the widget "prompt".
from tkinter import *
from tkcalendar import *
from array import *
root = Tk()
i = 0
def getDateA():
a = array('b',[]*10000)
global i
f = i + 1
c = int(dataC.get())
b = int(dataB.get())
g = dataA.get()
a.append(g[f])
d = int(a[b]) + int(a[c])
prompt.configure(text = d)
dataA = Entry(root, text="Enter a", width = 20)
dataA.grid(column = 2)
dataB = Entry(root, text="Enter b", width = 20)
dataB.grid(column = 3)
dataC = Entry(root, text="Enter c", width = 20)
dataC.grid(column = 4)
my_button = Button(root, text="get date", command=getDateA)
my_button.grid(column = 2)
prompt = Label(root, text="Ingenting")
prompt.grid(column=1)
root.mainloop()
At first, the array wasn't long enough, so I added append, but I still got the error message (at the bottom of this post).
Then I initialized and - hopefully - added 10000 empty indexes. Still, I get the following error message:
Exception in Tkinter callback Traceback (most recent call last):
File "C:\Python38\lib\tkinter_init_.py", line 1883, in call return self.func(*args) File "Linear algebra.py", line 16, in getDateA a.append(g[f]) IndexError: string index out of range
Why is that?