Reputation: 27
this is pretty much my code, the submit button is disabled until the string button is used. What I'd like to do is to have the disabled again if there is any edit to the name and surname entry or maybe, if it is simpler, just if they are clicked. How could I achieve this? thank you
surname = Label(self, text="surname:", font=('arial', 12)).place(relx=0.07, rely=0.093, height=15, width=100)
def edit_name(event):
self.name.config(state='disable')
self.name = StringVar(self)
self.name.set('')
self.name=Entry(self,textvariable = self.name, width=280, bg='WHITE')
self.name.place(relx=0.19, rely=0.05, height=25, width=160)
self.name.bind("<KeyRelease>", edit_name)
self.surnname = StringVar(self)
self.surname.set('')
self.surname=Entry(self,textvariable = self.surname, width=280, bg='WHITE')
self.surname.place(relx=0.19, rely=0.090, height=25, width=160)
```
Upvotes: 0
Views: 104
Reputation: 3323
You can bind callbacks to any event on name and surname Entry widget eg:
self.surname.bind("<KeyRelease>", self.__onSurnameEdited)
Then in the callback you can modify the visibility of the button
For a list of events see here: List of All Tkinter Events
Upvotes: 1