from Tkinter import
This is a syntax error. When using the from
syntax, you need to list the names you want imported. (or an asterisk to import everything, but that's not good practice since it pollutes your namespace unnecessarily)
from Tkinter import Tk, PhotoImage, Label
label = Label(app, image = photo)
app.mainloop()
label.pack()
You're supposed to pack()
your widgets before you call mainloop. Change this to:
label = Label(app, image = photo)
label.pack()
app.mainloop()
photo = PhotoImage("Python.png")
You're supposed to use the file
keyword argument if you want to pass a filename to PhotoImage. Additionally, PhotoImage doesn't know how to open pngs. Try a format such as gif or pgm.
photo = PhotoImage(file="Python.gif")
Alternatively, install the third party library Pillow, and use its ImageTk.PhotoImage class, which supports a wide variety of image formats, including png.
from PIL import Image, ImageTk
img = Image.open("python.png")
photo = ImageTk.PhotoImage(img)
label = Label(app, image = photo)
End result:
from Tkinter import Tk, PhotoImage, Label
def start_up():
app = Tk()
app.title("Tower")
app.geometry('600x900')
photo = PhotoImage(file="Python.gif")
label = Label(app, image = photo)
label.pack()
app.mainloop()
start_up()