`
`D={}
lang=[]
Lrow=[0,1,2,3,4]
Lcolumn=[0,1,2,3]
for num1 in Lrow:
for num2 in Lcolumn:
pair=str(num1)+str(num2)
lang.append(pair)
data=gettingdata.orderbyavailableartasc()
listcount=0
for record in data:
referenceid=record[0]
D[lang[listcount]]=referenceid
listcount+=1
print(D)
rowcount=0
for i in range(5):
if i%2==0:
if rowcount!=0:
rowcount+=1
for k in range(4):
y=Button(artdisplay,bg="black",width=24,height=10)
y.grid(row=i,column=k,padx=10,pady=10)
gridpair=str(rowcount)+str(k)
imagename=D[gridpair]+" thumbnail.png"
displaythumbnail=Image.open(imagename)
photoimagethumbnail=ImageTk.PhotoImage(displaythumbnail)
y.configure(image=photoimagethumbnail)
else:
rowcount+=1
for k in range(4):
y=Button(artdisplay,bg="black",width=24,height=10)
y.grid(row=i,column=k,padx=10,pady=10)
gridpair=str(rowcount)+str(k)
imagename=D[gridpair]+" thumbnail.png"
displaythumbnail=Image.open(imagename)
photoimagethumbnail=ImageTk.PhotoImage(displaythumbnail)
y.configure(image=photoimagethumbnail)
There is a frame which has 20 buttons. I want these buttons to have images. For that I created a dictionary ( keys being the positions of the buttons according to grid system like 00,01 and so on... and values being the names of the images). Through a loop I took the names of the images(referenceids) and then consequently configured the buttons in the loop. When I ran the code, there was no error but the frame in which the buttons were present got reduced to an extremely small size and all the buttons in it got diminished.**They also did not have the images on them. ** Now, when I created the thumbnail images, I kept the size of the images equal to that of the buttons so they fit in perfectly.
Can anyone help me figure out the cause of the problem?