Self is not defined?
<p>I am attempting to make a basic study clock as a learning exercise for Tkinter but I get an error when attempting run it saying self is not defined. Here is the error message.</p>

<pre><code>Traceback (most recent call last):
    File "productivityclock.py", line 6, in &lt;module&gt;
        class gui(object):
    File "productivityclock.py", line 113, in gui
        while 0 &lt; self.z:
NameError: name 'self' is not defined
</code></pre>

<p>Here is my code, I would really appreciate if someone could help me out, Thanks</p>

<pre><code>from Tkinter import *
import time

root = Tk()

class gui(object):
def __init__(self, master):

    self.frame = Frame(master)
    self.frame.pack()

    t_int = 0
    b_int = 0
    reps = 0

    self.menu()

    def menu(self): 
        self.button1 = Button(
        self.frame, text="Set Time", command = self.set_time)
        self.button2 = Button(
        self.frame, text="Set Breaks", command = self.set_break)
        self.button3 = Button(
        self.frame, text="Set Intervals", command = self.set_reps)
        self.button4 = Button(
        self.frame, text="Start", command = self.timer)
        self.button1.pack(side = LEFT)
        self.button2.pack(side = LEFT)
        self.button3.pack(side = LEFT)
        self.button4.pack(side = LEFT)

    def set_time(self):
        self.button1.pack_forget()
        self.button2.pack_forget()
        self.button3.pack_forget()
        self.button4.pack_forget()

        self.l = Label(self.frame, text = "Enter the time of each study session (minutes)")
        self.button = Button(
        self.frame, text="Get", command=self.on_button1)
        self.entry = Entry(self.frame)
        self.button.pack(side = RIGHT)
        self.entry.pack(side = LEFT)
        self.l.pack(side = LEFT)

    def set_break(self):
        self.button1.pack_forget()
        self.button2.pack_forget()
        self.button3.pack_forget()
        self.button4.pack_forget()

        self.l = Label(self.frame, text = "Enter the time of each break (minutes)")
        self.button = Button(
        self.frame, text="Get", command=self.on_button2)
        self.entry = Entry(self.frame)
        self.button.pack(side = RIGHT)
        self.entry.pack(side = LEFT)
        self.l.pack(side = LEFT)

    def set_reps(self):
        self.button1.pack_forget()
        self.button2.pack_forget()
        self.button3.pack_forget()
        self.button4.pack_forget()

        self.l = Label(self.frame, text = "Enter the amount of study sessions (minutes)")
        self.button = Button(
        self.frame, text="Get", command=self.on_button3)
        self.entry = Entry(self.frame)
        self.button.pack(side = RIGHT)
        self.entry.pack(side = LEFT)
        self.l.pack(side = LEFT)

    def on_button1(self):
        x = self.entry.get()
        self.t_int = x
        print self.t_int

        self.button.pack_forget()
        self.entry.pack_forget()
        self.l.pack_forget()

        self.menu()

    def on_button2(self):
        x = self.entry.get()
        self.b_int = x
        print self.b_int

        self.button.pack_forget()
        self.entry.pack_forget()
        self.l.pack_forget()

        self.menu()

    def on_button3(self):
         x = self.entry.get()
         self.reps = x
         print self.reps

         self.button.pack_forget()
         self.entry.pack_forget()
         self.l.pack_forget()

         self.menu()

    def timer(self):
         x = self.t_int
         y = self.b_int
         self.z = self.reps


         while 0 &lt; self.z:
             while x &gt; 0:
                 time.sleep(60)
                 n = Label(self.frame, text = "You have %r minutes left in your session") % x
                 n.pack(side = LEFT)
                 x = x - 1
             n.pack_forget
             while y &gt; 0:
                 time.sleep(60)
                 self.e = Label(self.frame, text = "You have %r minutes left in your break") % y
                 self.e.pack(side = LEFT)
                 self.y = self.y - 1
             self.e.pack_forget()

             z = z - 1
             x = self.t_int
             y = self.b_int


app = gui(root)

root.mainloop()
</code></pre>

<p>Yes, at line 113, <code>while 0 &lt; self.z:</code> is not properly indented, and all the lines below it.</p>

python python-2.7 tkinter