1

I've been trying to create a simple scenario game and I can't seem to get the image to display after the title. I would appreciate it if someone could help me. Here is the code:

import tkinter
from PIL import ImageTk, Image

def page1():
    page1text2.pack()
    page2text.pack_forget()
    img = ImageTk.PhotoImage(Image.open("game.ppm"))
    imglabel = tkinter.Label(window, image=img).grid(row=1, column=1)
    
def page2():
    page1text2.pack_forget()
    page2text.pack()

window = tkinter.Tk()

page1btn = tkinter.Button(window, text="Page 1", command=page1)
page2btn = tkinter.Button(window, text="Page 2", command=page2)

page2text = tkinter.Label(window, text="This is page 2")
page1text2 = tkinter.Label(window, text="Forest Camping Trip", fg="red", font="Times 50 bold")

page1btn.pack()
page2btn.pack()


window.mainloop()

0 Answers0