Home>

I can't set my photo as a background.
Instead, a white square covers all buttons.

My code:

import random
from tkinter import *
from tkinter import filedialog
from pygame import mixer
from threading import Thread
from PIL import ImageTk, Image
import PyQt5
mixer.init()
class MusicPlayer:
    def __init__(self, window ):
        window.geometry('320x150'); window.title("Player"); window.resizable(0,0)
        Load= Button(window, text= 'Load', width= 10, font= ('Times', 10), command= self.load)
        Play= Button(window, text= 'Play', width= 10,font= ('Times', 10), command= self.play)
        Pause= Button(window,text= 'Pause', width= 10, font= ('Times', 10), command= self.pause)
        Stop= Button(window ,text= 'Stop', width= 10, font= ('Times', 10), command= self.stop)
        Volm= Button(window, text= "Volume -", width= 10, font= ("Times", 10), command= self.Volm)
        Volp= Button(window, text= "Volume +", width= 10, font= ("Times", 10), command= self.Volp)
        GetPos= Button(window, text= "Get Pos" , width= 10, font= ("Times", 10), command= self.getPos)
        Timem= Button(window, text= "Time -", width= 10, font= ("Times", 10), command= self.timeM)
        Timep= Button(window, text= "Time +", width= 10, font= ("Times", 10), command= self.timeP)
        background= Image.open("background.jpg")
        background_image= ImageTk.PhotoImage(background)
        background_label= Label(window, image=background_image)
        background_label.place(x=0, y=0, relwidth=1, relheight=1)
        mixer.music.set_volume(1)
        Load.place(x=0,y=20);Play.place(x=110,y=20);Pause.place(x=220,y=20);Stop.place(x=110,y=60 ); Volm.place(x=0, y=60); Volp.place(x=220,y=60); GetPos.place(x=110, y=100); timem.place(x=0, y=100); timep.place(x=220, y=100)
        self.music_file= False
        self.playing_state= False
    defload(self):
        self.music_file= filedialog.askopenfilename()
    defplay(self):
        if self.music_file:
            mixer.init()
            mixer.music.load(self.music_file)
            mixer.music.play()
    def pause(self):
        if not self.playing_state:
            mixer.music.pause()
            self.playing_state=True
        else:
            mixer.music.unpause()
            self.playing_state= False
    def stop(self):
        mixer.music.stop()
    def Volp(self):
        volume= mixer.music.get_volume()
        volume= volume * 100 + 5
        if(volume<= 100):
            mixer.music.set_volume(volume/100)
    defVolm(self):
        volume= mixer.music.get_volume()
        volume= volume * 100 -5
        if(volume >= 0):
            mixer.music.set_volume(volume/100)
    def getPos(self):
        pos= mixer.music.get_pos()/1000
        print(pos)
    def timeM(self):
        pos= mixer.music.get_pos()/1000
        mixer.music.play(0,int(pos)-5)
    def timeP(self):
        pos= mixer.music.get_pos()/1000
        mixer.music.play(0,int(pos)+5)
root= Tk()
app=MusicPlayer(root)
root.mainloop()