disabling button

devnew at gmail.com devnew at gmail.com
Sat Dec 22 07:56:18 EST 2007


using tkinter i created a gui and put a button on the frame

class mygui:
     def __init__(self, parent):
          ...
          self.okButton = Button(self.btnFrame)
          self.okButton.configure(width=somewdth,text="OK",
 
anchor=W,disabledforeground="tan")
          self.okButton.bind("<Button-1>",self.button1Click)

then in the buttonClick(self,event) i want to disable it till some
time consuming calculations  are completed ..then i enable it

         def  button1Click(self, event):
             self.okButton.configure(state=DISABLED)
             print "ok disabled"
             somebigcalculations()
             self.okButton.configure(state=NORMAL)
             print "ok enabled"

well,the button doesn't grey out when i  click it ,though the print
staements are executed..
but if some error happens and program exits with some ioerror(say
errno2 file not found ..)then the button is shown as greyed out..

am i missing something here ? how can i get the button disabled and
greyed out on clicking it?

dn






More information about the Python-list mailing list