GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support more options for reading/writing images in Tkinter · Issue #118271 · python/cpython

Support more options for reading/writing images in Tkinter #118271

New issue
Copy link
New issue
Copy link
Closed
Closed
Support more options for reading/writing images in Tkinter#118271
Copy link
Labels
3.13only security fixesonly security fixestopic-tkintertype-featureA feature request or enhancementA feature request or enhancement

Description

@serhiy-storchaka
serhiy-storchaka
opened on Apr 25, 2024
Issue body actions

Feature or enhancement

PhotoImage has method write() which writes the image (or its part) to the file. But it lacks methods for two other related subcommand -- read, to read the image from the file, and data, to get the image data. I propose to add methods read() and data().

Also, the write() method can support two new options: background and grayscale.

Linked PRs

  • gh-118271: Support more options for reading/writing images in Tkinter #118273

Activity

  1. serhiy-storchaka
    added
    type-featureA feature request or enhancementA feature request or enhancement
    topic-tkinter
    3.13only security fixesonly security fixes
    on Apr 25, 2024
  2. serhiy-storchaka commented on Apr 25, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Apr 25, 2024
    MemberAuthor
    More actions

    Note that some Tk commands have options which cannot be directly translated to Python parameters: class, in, from. Usually this is worked around by adding an underscore at the end. But in PhotoImage.write() the -from option was translated to from_coords. There is a precedence of using from_ in other place, so I used from_ in the new copying method (#118225) and in read() added here. It creates inconsistency with the write() method. Maybe we should use from_coords in all PhotoImage methods?

    cc @terryjreedy

  3. serhiy-storchaka commented on Apr 25, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Apr 25, 2024
    MemberAuthor
    More actions

    Yet one note: read -from does not work correctly with GIF and PNG images, unlike to copy -from. This is an old Tk bug https://core.tcl-lang.org/tk/tktview/1576528. A workaround is to read the whole file and then copy a region from the new image by using the new copying method.

    We may get reports about broken behavior when people start to use the new method with this option, but I think that it is worth to implement it. The Tk bug can finally be fixed in the future releases, and it works at least with PPM files.

  4. serhiy-storchaka
    added 2 commits that reference this issue on Apr 25, 2024

    pythongh-118271: Support more options for reading/writing images in T…

    432a235

    pythongh-118271: Support more options for reading/writing images in T…

    455252e
  5. serhiy-storchaka
    added a commit that references this issue on May 6, 2024

    gh-118271: Support more options for reading/writing images in Tkinter (…

    709ca90
  6. serhiy-storchaka
    closed this as completedon May 6, 2024
  7. SonicField
    added a commit that references this issue on May 8, 2024

    pythongh-118271: Support more options for reading/writing images in T…

    3d59bf5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixestopic-tkintertype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.