Image problem on a tkinter button

0

I want to put image on the buttons, I've done this before, but agr n is working. Can you help me?

** Detail: ** In the same tkinter window is instantiated the screen of a turtle.

def images(self):
    imgAdd = tk.PhotoImage(file='./Images/add3.png').subsample(20,20)
    imgDel = tk.PhotoImage(file='./Images/menos.png').subsample(20,20)
    imgTrash = tk.PhotoImage(file='./Images/trash2.png').subsample(20,20)
    imgConfig = tk.PhotoImage(file='./Images/engre3.png').subsample(20,20)

    self.Widgets(imgAdd,imgDel,imgTrash,imgConfig)

def Widgets(self,*args):
    self.Add = tk.Button(self.frame_left,bd=0,image=args[0],command='')
    self.Add.grid(padx=10)
    self.Config = tk.Button(self.frame_left,bd=0,image=args[3],command='')
    self.Config.grid(padx=10)
    self.Trash = tk.Button(self.frame_left,bd=0,image=args[2]',command='')
    self.Trash.grid(padx=10)
    
asked by anonymous 05.07.2017 / 03:55

1 answer

0

I also had this problem but I solved the variable "image": self.botao.image = image .

Then the code stayed like this

from tkinter import *

class Janela:
    def __init__(self, master):
        self.master = master
        self.master.geometry('300x200+200+100')

        self.botao = Button(self.master)
        imagem = PhotoImage(file='/Users/Luiz/Image/botao.png')
        self.botao.config(image=imagem)
        self.botao.imagem= imagem
        self.botao.pack()

root = Tk()
Janela(root)
root.mainloop()
    
17.01.2018 / 13:42