Python Forum
[Tkinter] Button States
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Button States
#5
(Jan-27-2021, 11:31 AM)steve_shambles Wrote: I think he just wants to know how to disable a button when clicked.

from tkinter import *
 
root = Tk()
 
def my_fun():
    #make the my_btn state disabled
    #do some thing else
    my_btn.config(state=DISABLED)

my_btn = Button(root, text = "CLICK ME", command = my_fun)
my_btn.pack()
The line you used with .pack on the end won't work in this scenario
so I changed that.

To re-enable the button change DISABLED to NORMAL.
Tysm it worked!
Reply


Messages In This Thread
Button States - by Oshadha - Jan-20-2021, 03:15 PM
RE: Button States - by buran - Jan-20-2021, 04:03 PM
RE: Button States - by deanhystad - Jan-20-2021, 06:32 PM
RE: Button States - by steve_shambles - Jan-27-2021, 11:31 AM
RE: Button States - by Oshadha - Feb-01-2021, 03:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,098 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020