Python Forum
[Tkinter] Why is it so difficult to just ouput an image where I want?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Why is it so difficult to just ouput an image where I want?
#5
(Apr-04-2019, 03:34 AM)woooee Wrote: This page referenced above, opens a jpeg and places it on a Label. Your code would be similar to place it on a Canvas https://effbot.org/tkinterbook/photoimage.htm

So here is the updated version. File exists as if I delete it, the program gives me a traceback showing it's missing. Like this, no errors but a blank canvas.
from Tkinter import *
from PIL import Image, ImageTk

root = Tk()
# Remove titlebar    
root.overrideredirect(1)
canvas = Canvas(root, width =100,height=153)
image = Image.open("pngs/a.jpg")
logo = ImageTk.PhotoImage(image)
#logo=PhotoImage(file="pngs/a.jpg)
canvas.create_image(200, 200, image=logo) #Change 0, 0 to whichever coordinates you need
root.mainloop()
If I only had the smarts to learn this stuff any more. Back in the days of wooden ships and iron men, all we had was FORTRAN.
Reply


Messages In This Thread
RE: Why is it so difficult to just ouput an image where I want? - by jpezz - Apr-05-2019, 12:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Switching from tkinter to gtk is difficult! snakes 1 1,505 Aug-08-2022, 10:35 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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