0

I have an issue with accessing to Tkinter button objects. My idea that 2nd button is disabled if first button wasn't pressed.

root

If 1st button is pressed TopLevel window pops up with input fields. toplevel

When 3rd button is pressed works my function.And I'd like to change text of 4th button and destroy 3rd button. I can't do that from my function

 self.win = tk.Toplevel()
    self.win.geometry('350x200')
    self.win.transient(root)
    self.win.grab_set()

 self.btn_cancel = tk.Button(master=self.win, text='Отмена', 
   command=self.win.destroy).grid(row=8, column=1)
 self.btn_conn = tk.Button(master=self.win, text='Проверить', 
   command=self.entry_db_check).grid(row=8, column=0)
 def entry_db_check(self):
 <my code is here>

After all manipulation 2nd button must be active. I saw that it should work so

 self.btn_cancel.destroy()
 self.btn_conn['text']='OK'

Should I switch to frames instead of TopLevel window to make it work?

Rostislav Aleev
  • 351
  • 5
  • 19
  • It would be _much_ better if you include error message. – Lafexlos Jan 09 '19 at 14:19
  • 2
    Just a guess: Since you are trying to access a button which uses `grid` in same line, you are probably getting `NoneType` error. Check this answer: https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-get – Lafexlos Jan 09 '19 at 14:20
  • 1
    @Lafexlos, yep. I solved my issue with that answer and didn't pay attention when created these buttons. Thank you. – Rostislav Aleev Jan 09 '19 at 14:29

0 Answers0