Python Forum

Full Version: question on tkinter canvas PhotoImage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to put an image in a window above the buttons.
but the window is blank where the canvas is supposed to be.?

from tkinter import *
from PIL import ImageTk,Image
root = Tk()
root.geometry("480x480")
root.title("planets")
label =Label(root , text = "what planet would you like to know about?")
label.grid(row =15 , column = 1)

canvas = Canvas(root , width = 200 , height = 200)
canvas.grid(row = 10 , column = 3 )

photo = PhotoImage('gif.gif')
canvas.create_image(0,0 , anchor = NW, image = photo)

root.mainloop()
add a frame, and/or panel directly on root window that spans entire window space.
(if you use both frame and panel (good practice), then create you other widgets, all on the Panel
Using this method, you will have complete control of where the widgets appear on the screen.

By the way, this reference manual is very useful, if you don't already have a copy:
http://reu.cct.lsu.edu/documents/Python_...kinter.pdf