Python Forum
[Tkinter] Image with pillow on macos not showing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Image with pillow on macos not showing
#2
Please attach image file

** Edited **

After thinking about this a bit, I think you just have to anchor your path:

#!/usr/local/bin/python3
import tkinter
from PIL import Image, ImageTk
import os

# Anchor path
os.chdir(os.path.abspath(os.path.dirname(__file__)))

img = Image.open('images/img.jpg')
root = tkinter.Tk()
canvas = tkinter.Canvas(root, width=img.width, height=img.height,
    background='blue', borderwidth=0, )
canvas.pack()
tkimg = ImageTk.PhotoImage(img)
imagesprite = canvas.create_image(0, 0, anchor=tkinter.NW, image=tkimg)
root.mainloop()
Reply


Messages In This Thread
RE: Image with pillow on macos not showing - by Larz60+ - May-04-2019, 05:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  macOS Sonoma (14) seems to need a newer version of Tcl/Tk gernophil 1 1,171 Oct-11-2023, 05:53 PM
Last Post: deanhystad
  UI modules: which is most suitable for macOS app design? Anon_Brown 1 1,919 Nov-19-2021, 06:24 PM
Last Post: Larz60+
  [Tkinter] image in label not showing? rwahdan 2 8,359 Jun-25-2021, 10:27 AM
Last Post: rwahdan
  tkinter showing image in button rwahdan 3 5,725 Jun-16-2021, 06:08 AM
Last Post: Yoriz
  macOS GUI pythonnewbi 5 3,112 Jul-05-2020, 03:56 PM
Last Post: ndc85430
  Pillow juuls04 4 3,359 Dec-30-2019, 04:55 AM
Last Post: joe_momma
  [Tkinter] macOS Catalina and Python menu issue SouthernYankee 7 6,924 Dec-11-2019, 02:02 AM
Last Post: chrstphrchvz
  Packaging VTK and ITK for macOS sandrider 0 2,044 Nov-01-2018, 05:24 AM
Last Post: sandrider
  About Dialog in PyQt5 on macOS cpuin 0 2,911 Jan-23-2018, 08:50 PM
Last Post: cpuin
  packaging a PyQt app for macOS danboid 0 3,158 Mar-30-2017, 06:57 PM
Last Post: danboid

Forum Jump:

User Panel Messages

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