Python Forum
MP3 Player Images Not Showing - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: MP3 Player Images Not Showing (/thread-29086.html)



MP3 Player Images Not Showing - Harshil - Aug-17-2020

Hey! Friends I Am Working On A MP3 Player But Problem IS Image Is Not Showing!!
from tkinter import *
import pygame
window = Tk()
window.iconbitmap('logo.ico')
window.title("MP3 PLAYER")
window.geometry("500x300")
#INITIALIZE PYGAme
pygame.mixer.init()
#Create A Playlist
song_list = Listbox(window,bg='black',fg='green',width=60)
song_list.pack(pady=20)

#Define Player Buttons Image
play_btn_img = PhotoImage(file='play.png')
pause_btn_img = PhotoImage(file='pause.gif')
backward_btn_img = PhotoImage(file='backward.png')
forward_btn_img = PhotoImage(file='forward.png')
stop_btn_img = PhotoImage(file='stop.png')
#Create Player Control Frame
control_frames = Frame(window)
control_frames.pack()

#Create Player Button
backward_button = Button(control_frames,image=backward_btn_img)
forward_button = Button(control_frames,image=forward_btn_img)
start_button = Button(control_frames,image=play_btn_img)
stop_button = Button(control_frames,image=stop_btn_img)
pause_button = Button(control_frames,image=pause_btn_img)

#Grids
backward_button.grid(row=0,column=0,padx=10)
forward_button.grid(row=0,column=1,padx=10)
start_button.grid(row=0,column=2,padx=10)
stop_button.grid(row=0,column=3,padx=10)
pause_button.grid(row=0,column=4,padx=10)


window.mainloop()



RE: MP3 Player Images Not Showing - Axel_Erfurt - Aug-17-2020

If the images are located in the script folder

# get script dir
script_dir = os.path.dirname(sys.argv[0])
play_btn_img = PhotoImage(file=f'{script_dir}/play.png')



RE: MP3 Player Images Not Showing - Harshil - Aug-18-2020

(Aug-17-2020, 08:17 PM)Axel_Erfurt Wrote: If the images are located in the script folder

# get script dir
script_dir = os.path.dirname(sys.argv[0])
play_btn_img = PhotoImage(file=f'{script_dir}/play.png')

Thanks For Advice I Found That PNG File Pixels are 1000x1000 i need to resize but another problem is there