tkinter's image is inserted with extra sides

Viewed 48

I wanted to create a graphical interface for my project, but when I tried to insert the project logo into tkinter, the logo was displayed with extra borders, which are not in the image itself.

import tkinter as tk

from PIL import Image, ImageTk

height: int = 500
width: int = 700
root = tk.Tk()
root.title("quick_trade")
root.geometry(f"{width}x{height}")
root.configure(background='#333')


def open_img(path, size=(250, 200)):
    x = path
    image = Image.open(x)
    image = image.resize(size, Image.ANTIALIAS)
    image = ImageTk.PhotoImage(image)
    return image


img = open_img('dark.PNG')
label = tk.Label(root, image=img)
label.pack()

root.mainloop()

image

1 Answers

Just set bd = 0 like

label = tk.Label(root, image=img,bd=0)

Alternatively, for your case, say:

label = tk.Label(root, image=img,bg='#333')

Hope this cleared the effect, as it did for me, do let me know.

Cheers

Related