I want to display the image.

Asked 2 years ago, Updated 2 years ago, 24 views

I'm practicing reading a book, but it doesn't show up, so I'm struggling.

Enter a description of the image here

Enter a description of the image here

python

2022-09-30 11:19

1 Answers

As far as I can see from the image, there seems to be an error in img=tkinter.PhotoImage(file="image/webpy.jpg") on line 11.

Now refer to the documentation for the tkinter package.

PhotoImage for images in PGM, PPM, GIF and PNG formats. The later is supported starting with Tk 8.6.
https://docs.python.org/ja/3/library/tkinter.html#images

Therefore, an error may have occurred because you have specified an image file in JPG format that is not supported.Therefore, instead of JPG images,

  • PGM
  • PPM
  • GIF
  • PNG

You should be able to view it by preparing an image file in one of the formats in and specifying it instead of "image/webpy.jpg".


2022-09-30 11:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.