Python Forum
question on tkinter canvas PhotoImage - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: question on tkinter canvas PhotoImage (/thread-29488.html)



question on tkinter canvas PhotoImage - gr3yali3n - Sep-05-2020

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()



RE: question on tkinter canvas PhotoImage - Larz60+ - Sep-05-2020

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_Course/tkinter.pdf