Python: Whole image not showing

262 views Asked by At

Today I was trying to learn how the PhotoImage works but I run into errors and problems non stop. After lots of research I finally get an image to show up BUT its not the whole image, just a piece of it.

Heres my code:

from tkinter import*

root = Tk()
canvas = Canvas( root , width=720 , height=480 )
originallogo = PhotoImage( file="Picture1.gif" )
canvas.create_image( 0, 0, image=originallogo )
canvas.grid()
root.mainloop()

I would post a screenshot of the outcome but I am not level 10 yet. Heres a link of it instead: https://www.dropbox.com/s/iiwsdmgvlhyhlef/Screen%20shot%202014-11-24%20at%208.34.51%20PM.png?dl=0

2

There are 2 answers

0
Bryan Oakley On BEST ANSWER

By default the center of the image will be placed at the given coordinates. If you want the upper left corner of the image to be at 0,0, add anchor="nw"

canvas.create_image(..., anchor="nw", ...)
0
0Cool On

There is a very simple solution to this. Change the position of the drawing of the image from 0,0 to different numbers until you get it into the right position that you desire.