I'm not sure whether this has been asked already or not, but I have multiple entry boxes in which contain a default piece of text. I am not trying to set a default piece of text, I'm trying to remove when the entry box is clicked. I want to be able to remove the default text as soon as the entry box is clicked so the user does not have to do so. I was wondering if someone could share a quick example on how this is done so I can implement.
def removeValue(event):
self.entry.delete(0, 'end')
return None
for i in range(1, numberOfStudents + 1):
for p in range(0,2):
self.entry = Entry(self.master)
if p == 0:
self.entry.insert(0, 'Enter name of student')
self.entry.place(x = 10, y = (i * 30) + 26)
self.entry.bind("<Button-1>", removeValue)
if p == 1:
self.entry.insert(0, 'Enter predicted')
self.entry.place(x = (getWidth(master) - 140), y = (i * 30) + 26)
self.entry.bind("<Button-1>", removeValue)
I have this so far, but only deletes the very last entry boxes text.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…