Python Forum
MP3 Player Images Not Showing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MP3 Player Images Not Showing
#1
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()
Reply
#2
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')
Reply
#3
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter button images not showing up lunacy90 7 1,563 Aug-31-2023, 06:39 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020