I have created normal gui program which reads the lines on the text files and show up in the text tk entry field. I want to auto increase the index of the line when I press the button, I am confused with while loop. The code what I did so far:
def forms(self):
b = tk.Button(bd ='4', text="Auto Fill", width = 20, command = self.autosave)
b.place (x=230, y=600)
c = tk.Button(bd ='4', text="Clear", width = 20, command = self.clear)
c.place (x=390, y=600)
d = tk.Button(bd ='4', text="Exit", width = 20, command = self.close)
d.place (x=550, y=600)
#Form Feilds Starts from Here:
self.date = tk.Label(font=('Arial', 13,'bold'), text = "Date: ",bg='white')
self.date.place(x=10,y=50)
self.ent_date = tk.Entry(bd='4',width='23')
self.ent_date.place(x=60, y=50)
def autosave(self):
a = 0
fp = open('image.txt')
s = fp.readlines()
line = s[a]
self.ent_date.insert(0, line[0])
box.showinfo('Success','Saved Successfully')
while true:
a += 1
The above code makes my program to freeze. How can I make the value of 'a' increase each time I click the autofill button..? Thanks in advance.!