Python Forum
question on tkinter canvas PhotoImage
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question on tkinter canvas PhotoImage
#1
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()
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner question re: Tkinter geometry return2sender 3 904 Jun-19-2023, 06:19 PM
Last Post: deanhystad
  Tkinter GUI question texan1836 3 1,819 Apr-13-2023, 03:12 AM
Last Post: deanhystad
  tkinter.TclError: can't invoke "canvas" command cybertooth 8 5,773 Feb-23-2023, 06:58 PM
Last Post: deanhystad
  simple tkinter question function call not opening image gr3yali3n 5 3,300 Aug-02-2022, 09:13 PM
Last Post: woooee
  [Tkinter] question for a tkinter dialog box RobertAlvarez424 2 2,203 Aug-25-2021, 03:08 PM
Last Post: RobertAlvarez424
  [Tkinter] Clickable Rectangles Tkinter Canvas MrTim 4 8,660 May-11-2021, 10:01 PM
Last Post: MrTim
  [Tkinter] Draw a grid of Tkinter Canvas Rectangles MrTim 5 7,758 May-09-2021, 01:48 PM
Last Post: joe_momma
Thumbs Up tkinter canvas; different page sizes on different platforms? philipbergwerf 4 4,034 Mar-27-2021, 05:04 AM
Last Post: deanhystad
  Python tkinter question tablet Nick_tkinter 8 4,921 Mar-04-2021, 10:44 PM
Last Post: Larz60+
  tkinter slider question Nick_tkinter 1 2,433 Feb-22-2021, 01:31 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020