disabling button
Fredrik Lundh
fredrik at pythonware.com
Sat Dec 22 08:43:19 EST 2007
devnew at gmail.com wrote:
> 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)
+ self.okButton.update_idletasks()
> 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?
when Tkinter needs to redraw things, it adds the redraw action to an
internal "task" queue. tasks in this queue are usually handled by the
main event loop, but that loop doesn't run when you do your big
calculations. an explicit call to "update_idletasks" will clear out the
task queue for you.
</F>
More information about the Python-list
mailing list