I'm building a GUI using Tkinter and I've to create class StringVar atributes depending on a variable called initial_numbers. If initial_numbers is 5, I've to create 5 StringVars() with the name self.string_var plus a number so I can identify them.
If:
self.initial_numbers = 5
I've to create
self.string_var0 = StringVar()
self.string_var1 = StringVar()
self.string_var2 = StringVar()
self.string_var3 = StringVar()
self.string_var4 = StringVar()
After creating them, I want to add them to a list called stringList
What I've tryed this, but of course it's not working.
self.initial_numbers = 5
stringList = []
for i in xrange(int(self.initial_numbers)):
self.string_var+str(i) = StringVar()
self.string_var+str(i).set("test")
stringList.append(self.date_string+str(i))
Thanks in advance.