1

When I upload an Image in tkinter there is a white frame around the picture. I searched a lot but I didn't foud any answer.

Picture of the white frame: screenshot

Here is my code:

from tkinter import *

from PIL import ImageTk,Image

root = Tk()

root.geometry("1200x583")

root.resizable(0,0)

place_one=Image.open("p1.jpg")

place_one=place_one.resize((1200,583))

place_one_2=ImageTk.PhotoImage(place_one)

place=Label(root,image=place_one_2)

place.place(x=-2,y=0)

character=Image.open("m2.gif")

character=ImageTk.PhotoImage(character)

L1=Label(root,image=character)

L1.place(x=0,y=355)

root.mainloop()

1 Answers1

1

You need to set image border width (borderwidth) ,

L1=Label(root,image=character, borderwidth=0)

Edit: Do not use import *(why it is bad?) try to,

import tkinter as tk
from PIL import ImageTk,Image

root = tk.Tk()

root.geometry("1200x583")
root.resizable(0,0)

place_one=Image.open("p1.jpg")
place_one=place_one.resize((1200,583))
place_one_2=ImageTk.PhotoImage(place_one)

place=tk.Label(root,image=place_one_2)

0place.place(x=-2,y=0)

character=Image.open("m2.gif")
character=ImageTk.PhotoImage(character)

L1=tk.Label(root,image=character, borderwidth=0)
L1.place(x=0,y=355)

root.mainloop()
Avishka Dambawinna
  • 1,180
  • 1
  • 13
  • 29