[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Images on Dynamically Generated Buttons Glitch

Greetings, i have this snippet:
import json
import os
from tkinter import *
from tkinter.ttk import *

root = Tk()
jload = json.load
buttons = list()
programs = os.listdir('programs')
for i, program in enumerate(programs):
    jsonpath = 'programs/{}/cmdlaunch.json'.format(program)
    info = jload(open(jsonpath))
    photo = PhotoImage(file = 'icons/'+info['icon'])
    photoimage = photo.subsample(3, 3)
    buttons.append(Button(root, text = 'Click Me !', image = photoimage,
                        compound = LEFT))


All buttons are appearing but only the last button is displaying the image,
any idea?

Abdur-Rahmaan Janhangeer