Home > database >  How do I make this button be disabled and say "Booked" when clicked in tkinter
How do I make this button be disabled and say "Booked" when clicked in tkinter

Time:07-15

So, im designing a restaurant management system using tkinter and im trying to make the table booking system right now ive got a button setup to book the table and i want it so when its clicked it becomes gray and says booked but idk how to do that can anyone help thanks

window = Tk()
window.title("Restaurant Manager V2")
window.geometry("600x300")
#setup tkinter label
label1 = Label(window, text="Click button to book table")
label1.grid(row=0, column=1, sticky=W)
#setup tkinter button
def button_click():


button1 = Button(window, text="Table 1", width=5, command=button_click)
button1.grid(row=2, column=0, sticky=W)
window.mainloop()

CodePudding user response:

def button_click():
    button1.config(state="disabled")
    button1["text"] = "Booked"

CodePudding user response:

you can this with 2nd way

def button_click():
             
                 button1 = Button(window, text="Booked !", width=5, 
                           state="disabled")
                 button1.grid(row=2, column=0, sticky=W)
  • Related