trying to change the state of button after the all the entry are updated
<p>trying to get my head around how to enable the state of the button after the entries are written. I am trying to get a new window Toplevel. Wherein, there are three entry widgets. After they are filled with values the RUN button should be enabled. I know i gotta use the trace method to attach observer callbacks to the variables. This is what i have done so far.</p>

<pre><code>class appl:
    def __init__(self, master):
        self.master = master
        self.frame = tk.Frame( self.master, width=800, height=700 )
        self.var = tk.IntVar( )
        self.func1 = tk.Radiobutton( self.frame, text='fun1', value=1, variable=self.var,command=self.new_window )
        self.func1.pack( )
        self.frame.pack( )
    def new_window(self):
        self.newWindow = tk.Toplevel(self.master)
        self.intvar1 = tk.IntVar()
        self.intvar2 = tk.IntVar()
        self.intvar3 = tk.IntVar()
        self.ent = tk.Button( self.newWindow, text='ENTER', state='disabled', command=self.validate_check ).grid(row=3, column=1 )
        self.intvar1.trace( 'w', self.validate_check )
        self.intvar2.trace( 'w', self.validate_check )
        self.intvar3.trace( 'w', self.validate_check )
        self.X = tk.Entry( self.newWindow,textvariable=self.intvar1 )
        self.Y = tk.Entry( self.newWindow, textvariable=self.intvar2)
        self.Z = tk.Entry( self.newWindow, textvariable=self.intvar3)
        self.X.grid( row=0, column=1 )
        self.Y.grid( row=1, column=1 )
        self.Z.grid( row=2, column=1 )
        tk.Label( self.newWindow, text=" X" ).grid( row=0 )
        tk.Label( self.newWindow, text=" Y" ).grid( row=1 )
        tk.Label( self.newWindow, text=" Z" ).grid( row=2 )
    def validate_check(self, *args):
        x = self.intvar1.get()
        y = self.intvar2.get()
        z = self.intvar3.get()
        if x and y and z:
            self.ent.config(state=NORMAL)
        else:
            self.ent.config(state=DISABLED)
def main():
    root = tk.Tk()
    app = appl(root)
    root.mainloop()
if __name__ == '__main__':
    main() 
</code></pre>

<p>Your code is almost working except:</p>

<pre><code>self.ent = tk.Button( self.newWindow, text='ENTER', state='disabled', command=self.validate_check ).grid(row=3, column=1 )
</code></pre>

<p>should be:</p>

<pre><code>self.ent = tk.Button( self.newWindow, text='ENTER', state='disabled', command=self.validate_check )
self.ent.grid(row=3, column=1 )
</code></pre>

<p>Also, when you input something other than <code>0-9</code> in the entry boxes, <code>validate_check(...)</code> will raise exception because the entry text cannot be converted to integer value.  Try changing <code>validate_check(...)</code> to:</p>

<pre><code>def validate_check(self, *args):
    try:
        x = self.intvar1.get()
        y = self.intvar2.get()
        z = self.intvar3.get()
        # all three entries are valid integers, enable the button
        self.ent.config(state=tk.NORMAL)
    except:
        # something wrong on the entries, disable the button
        self.ent.config(state=tk.DISABLED)
</code></pre>

python tkinter