I'm trying to make a very simple program. I have made one similar to this and it worked. however this one is giving me the error. The second button in the code is where the error speaks of. I have no idea whats wrong. I'm new to programming. Any help would be most appreciated.
AttributeError: App instance has no attribute 'h_one'
My code:
from Tkinter import *
import tkMessageBox
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(
frame, text="QUIT", fg="red", command=frame.quit
)
self.button.pack(side=LEFT,padx=5)
self.hone = Button(frame, text="Happy #1", command=self.h_one)
self.hi_there.pack(side=BOTTOM,pady=5)
self.htwo = Button(frame, text="Happy #2", command=self.h_two)
self.hi_there.pack(side=BOTTOM,pady=5)
self.hthree = Button(frame, text="Happy #3", command=self.h_three)
self.hi_there.pack(side=BOTTOM,pady=5)
def h_one(self):
print "1"
def h_two(self):
print "2"
def h_three(self):
print "3"
frame=Tk()
frame.title("Mad Mike's Happy Tool")
frame.geometry("360x400+200+200")
label0 = StringVar()
label0.set("MMHT")
labelA = Label(frame, textvariable=label0, height = 4)
labelA.pack(side=BOTTOM)
app = App(frame)
frame.mainloop()
frame.destroy()
h_oneand the other methods are indented further than the__init__method? Try to fix that.