tkinter "Class" has no attribute "button" even though is set in an instance
<p>I'm trying run example from this <a href="http://zetcode.com/articles/tkinterlongruntask/" rel="nofollow">tutorial</a> and getting an error:</p>

<pre><code>self.startBtn.config(state=tk.DISABLED) AttributeError: 'Example' object has no attribute 'startBtn'
</code></pre>

<p>I rewrite my code for simplicity (and get still the error):</p>

<pre><code>  #!/usr/bin/env python3

    import tkinter as tk


    class Example(tk.Frame):

        def __init__(self, parent):
            tk.Frame.__init__(self, parent)
            self.grid()

            startBtn = tk.Button(self, text="Start", command=self.disableButton)
            startBtn.grid(row=0, column=0, padx=10, sticky=tk.E)

        def disableButton(self):
            self.startBtn.config(state=tk.DISABLED)


    def main():

        root = tk.Tk()
        root.geometry("400x300")
        app = Example(root)
        app.mainloop()


    if __name__ == '__main__':
        main()
</code></pre>

<p>What I missed? </p>

<hr>

<p>Actualization
I forgot mention that program is able to compile and error occurs when button is pressed.</p>

<p>In the <em>function</em>, you use:</p>

<pre><code>def disableButton(self):
    self.startBtn.config(state=tk.DISABLED)
</code></pre>

<p>but the <em>button is created</em> without <code>self</code>:</p>

<pre><code>startBtn = tk.Button(self, text="Start", command=self.disableButton)
startBtn.grid(row=0, column=0, padx=10, sticky=tk.E)
</code></pre>

<p>Simply make it: </p>

<pre><code>    self.startBtn = tk.Button(self, text="Start", command=self.disableButton)
    self.startBtn.grid(row=0, column=0, padx=10, sticky=tk.E)

def disableButton(self):
    self.startBtn.config(state=tk.DISABLED)
</code></pre>

<p>...to be able to configure the button's state in the function.</p>

python class tkinter