disabling button

damonjulian at yahoo.com damonjulian at yahoo.com
Sat Dec 22 13:13:12 EST 2007



if you disable the button it can still respond to clicks? it only
greys out.. or is there a problem with my code here?

class MyApp:
	def __init__(self,parent):
		self.mainframe=Frame(parent)
		self.mainframe.pack()


		self.button1=Button(self.mainframe,bg="green")
		self.button1.configure(text="1")
		self.button1.pack(side=LEFT)
		self.button1.bind("<Button-1>",self.buttonClick1)
		self.button2=Button(self.mainframe,bg="yellow")
		self.button2.configure(text="2")
		self.button2.pack(side=LEFT)
		self.button2.bind("<Button-1>",self.buttonClick2)
		self.button3=Button(self.mainframe,bg="red")
		self.button3.configure(text="3")
		self.button3.pack(side=RIGHT)
		self.button3.bind("<Button-1>",self.buttonClick3)

	def buttonClick1(self,event):
		print "ok clicked"
		self.button2.configure(state=DISABLED)
		self.button2.update_idletasks()

	def buttonClick2(self,event):
		print "2 clicked"

	def buttonClick3(self,event):
		print "3 clicked"
		self.button2.configure(state=NORMAL)
		#self.button2.update_idletasks()



root = Tk()
myapp = MyApp(root)
root.mainloop()


here when u click button 1 ,the button2 greys out but can still
respond to clicks..is there a way to truly disable it?

damon



More information about the Python-list mailing list