0

I've been trying to have an image as background for my project. I found some code that places it in a label and this works fine except the sizing of it doesn't seem to work and empty spaces show up on the sides (see picture)enter image description here

My code is:

from tkinter import *
from PIL import ImageTk, Image


#make a window
ws = Tk()
ws.title("window")

#get wigth & height of screen
width= ws.winfo_screenwidth()
height= ws.winfo_screenheight()

#set screensize as fullscreen and not resizable
ws.geometry("%dx%d" % (width, height))
ws.resizable(False, False)

# put image in a label and place label as background
imgTemp = Image.open("images/wallpaper.png")
img2 = imgTemp.resize((height,1800))
img = ImageTk.PhotoImage(img2)

label = Label(ws,image=img)
label.pack(side='top',fill=Y,expand=True)

#text = Text(ws,height=10,width=53)
#text.place(x=30, y=50)

#button = Button(ws,text='SEND',relief=RAISED,font=('Arial Bold', 18))
#button.place(x=190, y=250)

ws.mainloop()
Bous
  • 23
  • 2
  • 6
  • Simply change `img2 = imgTemp.resize((height,1800))` to `img2 = imgTemp.resize((width,height))` – acw1668 Nov 11 '21 at 09:34

0 Answers0