0

for my program I need to place an transparent image on top of multiple frames (as a kind of overlay), and apparently, placing the image in a canvas is a good way to do it as they support transparency. However, the canvas has a non-transparent border around it, which means it just sits on top of the frames with a a gray rectangular background around it, and I have no clue how to fix it:

from tkinter import *
root = Tk()
root.title("Transparency")
root.geometry("500x500")
frame = Frame(root, width=500, height=500, bg="yellow")
frame.place(x=0, y=0)
photoimage = PhotoImage(file="example1.png")
canvas = Canvas(frame, width=300, height=200, bg="red")
canvas.create_image(128, 64, image=photoimage)
canvas.place(x=100, y=100)
root.mainloop()

This is not my actual program, but it does replicates what happens. I also need to use the Place manager instead of the others (my program uses a lot of coordinates to place several widgets). This is what it looks like when running the above code

This is what I want it to look like (assume the yellow underneath the image are a bunch of frames).

All I am trying to do is place a transparent Canvas on top of opaque Frames, and it should be impossible to tell that the Canvas is even present.

How do I accomplish this?

flamebull5
  • 17
  • 4
  • 1
    Possible duplicate of [How do I remove the light grey border around my Canvas widget?](https://stackoverflow.com/questions/4310489/how-do-i-remove-the-light-grey-border-around-my-canvas-widget) – ipaleka Jul 17 '19 at 00:07
  • What OS are you on? – Reblochon Masque Jul 17 '19 at 00:10
  • Windows 10, running Python 3.6.0 – flamebull5 Jul 17 '19 at 13:30
  • @ipaleka that does not work as that user is not dealing with transparency - they also completely fill their canvas so there is no background to eliminate, which is what I am trying to do. – flamebull5 Jul 18 '19 at 13:50
  • @flamebull5: the first answer for my linked question answers the following: "However, the canvas has a non-transparent border around it, which means it just sits on top of the frames with a big rectangular border around it, and I have no clue how to fix it:" – ipaleka Jul 18 '19 at 14:05
  • @ipaleka Sorry, my fault. Wrong choice of words. I've corrected it now. – flamebull5 Jul 18 '19 at 16:06

0 Answers0