CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

Label image white border

Open N4GR opened this issue 1 year ago • 1 comments

Hello everyone, I've got a little on-going project of mine that I'm working on and I came across an issue that I'm unaware of a fix for - I've created a transparent window and am attempting to place an image label onto it to act like the background of the window; however, when attempting to do so there's this white, pixelated-like fuzzy border around the edges of the image; any help will be appreciated.

code:

class ui():
    def __init__(self) -> None:
        # Creating root window
        main_window = Win()
        #windll.shcore.SetProcessDpiAwareness(1)

        main_window.configure(bg = "white")
        main_window.attributes("-transparentcolor", "white")
        main_window.geometry(f"{WINDOW_WIDTH}x{WINDOW_HEIGHT}")

        # Creating main canvas
        main_canvas = tk.Canvas(
            master = main_window,
            height = WINDOW_HEIGHT,
            width = WINDOW_WIDTH,
            bd = 0,
            highlightthickness = 0,
            relief = "ridge"
        )
        main_canvas.place(x = 0, y = 0)

        # Applying root window background
        image = ctk.CTkImage(Image.open("assets/background.png"), size = (WINDOW_WIDTH, WINDOW_HEIGHT))
        
        background_image = ctk.CTkLabel(master = main_canvas, image = image, bg_color = "white", text = "")
        background_image.place(x = 0, y = 0)

        main_window.mainloop()

Resulting window sample with issue: image

Original image sample: image

N4GR avatar Jul 31 '24 09:07 N4GR

Hello! Well this is more like a tkinter problem... however the problem can be your configuration like this: main_window.configure(bg = "white") try changing to another color like red and if the border is red then this is the problem. If you can share all your code should be more easy to deal.

You can also try to remove the border when configuring with borderwidth=0.

Also make sure your image corner is fully transparent because when you place it and the corner is not fully transparent can occur such of things.

HojdaAdelin avatar Aug 04 '24 18:08 HojdaAdelin