Python Forum
[Tkinter] PhotoImage and Jpeg images.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] PhotoImage and Jpeg images.
#1
Hi,

I find that PhotoImage does not handle jpeg images while Tk does.

I am building an open source GUI generator based on Tkinter and would like to be able to handle jpeg images without forcing my users and their potential users to install a separate package like Pillow or PIL. It seems to me that since Tk supports jpeg images and since jpeg images are so popular, Tkinter should support them within the standard Python library. I don't mind having to import a module, but I don't like requiring the installation of a package to get functionality supported by Tk.

Earlier documentation of Tk says that the only formats supported are GIF and PNG. However, experimentation with Tk shows that it indeed supports both PNG and JPEG and corresponding experimentation with Tkinter shows that PNG images are supported by PhotoImage but not JPEG suggesting that PhotoImage has been updated to handle PNG. So why has it never been updated to handle JPEG images?

Am I missing something? Is there another way to support JPEG within the standard Python library? Suggestions very welcome.

Thanks in Advance,

Don
Reply
#2
(Jan-06-2018, 10:06 PM)rozen Wrote: So why has it never been updated to handle JPEG images?
It seems very plausible that it was not updated because one only needs two lines of code to handle JPEG images by importing PIL. Not updating the PhotoImage class for jpg means zero maintenance for the python team. It avoids duplicating existing functionalities. In fact it only penalizes people who refuse to install PIL. This may be too little motivation for the python devs...
Reply
#3
I don't believe that your suggested reason is a good reason at all. The problem is not that two lines of code need are needed but that a user needs to realize the requirement and to put in the lines repeatedly. It takes a fair amount of time to comb the skimpy documentation to find the requirement. Multiply the inconvenience by the number of users and it adds up; it's not a matter of refusing to install PIL, it is an annoyance particularly when one is learning Tkinter and probably Tk. The Tk folks thought it useful enough to include and I am glad they did. I hope the Tkinter maintainers are not satisfied with a partial interface to Tk.

Pushing the argument about duplicating functionality would lead to the complete removal of PhotoImage since it could be entirely replaced by PIL. I think that is the case but I cannot find definitive documentation of PhotoImage.

A very canny programmer I knew maintained that "The hallmark a good tool is that it be a delight to use". When PhotoImage doesn't handle a most common case it fails that criteria. And it impacts the building of tools based on Tkinter.

How does one make a feature request or bug report?
Reply
#4
(Jan-07-2018, 06:34 AM)rozen Wrote: How does one make a feature request or bug report?

You can start with this documentation. From what I understand from Python's philosophy, you'll have to propose the updated code yourself.

(Jan-07-2018, 06:34 AM)rozen Wrote: The hallmark a good tool is that it be a delight to use

I'm not sure many people think that tkinter is a delight to use. Tkinter is largely unpythonic. It is there because Guido van Rossum needed a minimal GUI toolkit to ship with Python a long long time ago and tcl/tk was one of the simplest available toolkits at the time. I think another reason why there is little effort in changing Tkinter is that most python GUI developers use other toolkits. Tkinter belongs to another generation.

Another example of this is the Idle editor that comes with Python. You don't need to install a separate editor to write python programs, but most people do because Idle is a minimal editor (it is not a delight to use!). It would be a waste of time for python devs to write a full featured modern editor while there are so many of them around.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  question on tkinter canvas PhotoImage gr3yali3n 1 2,125 Sep-05-2020, 12:18 PM
Last Post: Larz60+
  Get the parent label of a ImageTk.PhotoImage delphinis 1 2,401 Aug-02-2020, 03:21 PM
Last Post: deanhystad
  Gif with PhotoImage Friend 3 5,281 Jul-23-2019, 10:23 PM
Last Post: Friend
  Move PhotoImage dan789 2 2,698 Dec-19-2018, 06:00 PM
Last Post: dan789
  [Tkinter] createing a tkinter photoimage from array in python3 pootle 2 16,808 Oct-18-2016, 09:28 AM
Last Post: pootle

Forum Jump:

User Panel Messages

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