-1

When I click a button a new button displays but I want the previous clicked button to be disabled.

import tkinter as tk

def newbutton():  
    newbtn = tk.Button(app, text = "New Window button")
    newbtn.pack() 

app = tk.Tk()
buttonExample = tk.Button(app, text="Create new window", command=newbutton)
buttonExample.pack()

app.mainloop()
Advik
  • 43
  • 9

2 Answers2

1

hi there have you tried to use the state command like this

buttonExample = tk.Button(app, text="Create new window", command=newbutton, state=DISABLED)

1

You can implement a very simple function that can disable a button

def disableButton(my_button):
    my_button.config(state='disabled')

There is already a post on stack talking about that here

Xeyes
  • 583
  • 5
  • 25