I am trying to insert a pic into a tkinter button
This is my code:
from tkinter import *
import tkinter as tk
from PIL import Image,ImageTk,ImageOps
class main_class(tk.Tk):
def __init__(self):
self.window = tk.Tk()
self.window.geometry("1920x1080")
self.window.configure(background='grey')
#opening play pic and resizing it to fit into button
self.play_pic = Image.open("play_pic.jpg")
self.play_pic_size = (11,49)
self.play_pic = ImageOps.fit(self.play_pic,self.play_pic_size,Image.ANTIALIAS)
self.play_pic = ImageTk.PhotoImage(self.play_pic)
#play button
self.play_button = Button(self.window,image=self.play_pic,command = self.play,height =11 ,width = 49).place(x=800,y = 180)
self.window.mainloop()
def play(self):
print('Everything is working fine so far')
#creating an object
object = main_class()
object.play()
This is what the result should look like :
And this is what is happening :
This is the "play_pic.jpg" in case you need it:
Any help is much appreciated!!