It is possible to do what you are trying to do.
I have not come across a situation that would need to do it this way though.
Here is an example using exec to perform the commands per loop.
For more on the exec statement you can reed some documentation here
NOTE: Avoid this method and use the list/dict methods instead. This example is just to provide knowledge on how it would be possible in python.
from tkinter import *
class tester(Frame):
def __init__(self, parent, *args, **kwargs):
Frame.__init__(self, parent, *args, **kwargs)
self.parent = parent
self.ent0 = Entry(self.parent)
self.ent1 = Entry(self.parent)
self.ent2 = Entry(self.parent)
self.ent0.pack()
self.ent1.pack()
self.ent2.pack()
self.btn1 = Button(self.parent, text="Put numbers in each entry with a loop", command = self.number_loop)
self.btn1.pack()
def number_loop(self):
for i in range(3):
exec ("self.ent{}.insert(0,{})".format(i, i))
if __name__ == "__main__":
root = Tk()
app = tester(root)
root.mainloop()