0

I'm trying to import an image and recognize by text in Python using below commands but it shows error.

My code:

from Tkinter import *
import pygame
import pyttsx3

pygame.init()
engine = pyttsx3.init()

root = Tk()
root.title('Application')
root.geometry('1352x652+100+100')
root.config(background='white')

str1 = StringVar()
str1.set('Application name')

frame1 = Frame(root,bg='white')
frame1.grid()

Disp = Canvas(frame1, width=160,height=120,bg='white')
Disp.grid(row=1,column=3)
img =PhotoImage(file='Icone.png')
image = Disp.create_image(85,62,image = img)

error stack trace:

img =PhotoImage(file='Icone.png')
Image.__init__(self, 'photo', name, cnf, master, **kw)
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "Icone.png"
Gabriel M
  • 1,486
  • 4
  • 17
  • 25
Yume N
  • 1
  • 2
  • 1
    Python 2 does not supper png. You need to use PIL to support other file types. I know your tag says Python 3 but your import says Python 2 `from Tkinter import *`. [The Tkinter PhotoImage Class](http://effbot.org/tkinterbook/photoimage.htm) – Mike - SMT Dec 04 '18 at 15:49
  • Possible duplicate of [Tkinter.PhotoImage doesn't not support png image](https://stackoverflow.com/questions/27599311/tkinter-photoimage-doesnt-not-support-png-image) – j_4321 Dec 04 '18 at 16:05

0 Answers0