-2

I am trying to put an image on a tkinter button but it doesn't see to work.

root.geometry('512x512')
vbuckimage = tkinter.PhotoImage(file='vbuckicon.gif')
#vbucks button
vbucksButton = tkinter.Button(root,image=vbuckimage,height=5,width=10)

vbucksButton.place(x=256,y=256)
root.mainloop()

the image is in the same place as the .py file

patrickjlong1
  • 3,683
  • 1
  • 18
  • 32
Ben
  • 1
  • 2
  • 1
    It's looking for the file relative to your current working directory, which may not be the same as the location of the script. – Bryan Oakley Mar 14 '18 at 19:04

1 Answers1

0

You seem to have the same issue as here Try this solution :

import os
from tkinter import *
base_folder = os.path.dirname(__file__)
image_path = os.path.join(base_folder, 'vbuckicon.gif')
vbuckimage = PhotoImage(file=image_path)
Tuki
  • 81
  • 4