tkinter prob

JyotiC jyoti.chhabra at gmail.com
Mon Aug 21 04:00:07 EDT 2006


thanx
got the error,
but there is one more prob, button is  not coming to enable again. once
it is disabled
the error it's giving is:-

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
    return self.func(*args)
  File "<stdin>", line 23, in com
NameError: global name 'ENABLED' is not defined
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
    return self.func(*args)
  File "<stdin>", line 23, in com
NameError: global name 'ENABLED' is not defined


is ENABLED valid option?
Eric Brunel wrote:
> On Mon, 21 Aug 2006 08:50:29 +0200, JyotiC <jyoti.chhabra at gmail.com> wrote:
>
> > i have tried it out but it's not working.
> > this is the code
> >
> > from Tkinter import *
> >
> > class abc:
> >     def __init__(self,parent):
> >         #make container myparent
> >         self.myparent=parent
> >         self.myparent.geometry("500x200")
> >
> >         #make the initial frame
> >         self.frame=Frame(self.myparent)
> >         self.frame.pack()
> >
> >         self.var=IntVar()
> >         self.var.set(0)
> >
> >         a=Button(self.frame,text="button")
> >         a.pack()
> >
> >
> > Checkbutton(self.frame,text="hello",variable=self.var,command=self.com(a)).pack()
>
> This *calls* self.com(a) and assigns its *results* (which happens to be
> None) to the command option in your button. So your button does nothing.
>
> To do what you want, use:
>
>           self.a = Button(self.frame,text="button")
>           self.a.pack()
>           Checkbutton(self.frame,text="hello",variable=self.var,command=self.com).pack()
>
> in __init__, then:
>
>       def com(self):
>           if self.var.get()==1:
>               self.a.config(state=ENABLED)
>           else:
>               self.a.config(state=DISABLED)
>
> HTH
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in
> 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"




More information about the Python-list mailing list