I'm new to tkinter and can't seem to wrap my head around oop and I think that's where the problem lies.
This is my code:
from Tkinter import *
from PIL import ImageTk, Image
images = {
"first" : "miog.png",
"combat" : "mio kicking ass.jpg"
}
class App:
def __init__(self, master, image_dict):
frame = Frame(master)
frame.pack()
self.pic = ImageTk.PhotoImage(Image.open(image_dict["first"]))
self.image = Label(frame, image = self.pic)
self.image.pack(side = TOP)
self.button = Button(frame, text="Start", command=self.combat())
self.button.pack(side = RIGHT)
def combat(self):
self.button.destroy()
window = Tk()
window.title("aaa")
app = App(window, images)
window.mainloop()
The error I get from console is:
AttributeError: App instance has no attribute 'button'
I don't get it, wasn't button made when initializing the instance (in init)?
Every other answer I found for similar questions had to do with indentation, but I made sure to double check everything (all tabs and all where I think they should be).