Search code examples
pythonimagetkintercanvastkinter-canvas

i need to make an image in the canvas in tkinter heres the code but errors are coming


c = tkinter.Canvas(width=275,height=300)
so_ramdom = tkinter.PhotoImage("/Users/vikranthracherla/Downloads/download.jpeg")
c.create_image(image=so_ramdom)

the error

Traceback (most recent call last):
  File "d27.py", line 33, in <module>
    c.create_image(image=so_ramdom)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2325, in create_image
    return self._create('image', args, kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2309, in _create
    cnf = args[-1]
IndexError: tuple index out of range

Solution

  • You forgot to add coordinates x and y

    c.create_image(x, y, ..... Also noticed you are not passing in any coordinates onto.