Hi all,
i was writing a gui for a small desktop application i made as a part of learning python.I use python 2.7.I used Tkinter.I am new to python and this was my first trial with Tkinter.
First i created 9 buttons arranged in the form of a 3*3 matrix and set the image of the button as None.
frame=Frame(root,name='frame')
frame.pack(fill=BOTH, expand=1)
cols=1
rows=1
for i in range(1,10):
l=Button(frame,name=str(i),bg='red',fg='green',background='blue',width=8,height=4,image=None)
l.bind("<Button-1>",self.button_handle)
l.grid(row = rows, column =cols,sticky = W+E+N+S,)
self.label_list.append(l)
if i%3:
cols+=1
else:
rows+=1
cols=1
what i wanted to do is when i click on any of the buttons an image need to be displayed on the button.
for this i used another function.
img=PhotoImage(file="./cross.GIF")
def change_widget_icon(self,widget,img):
if widget==None:
widget=img
The problem i face is that when all the 9 buttons are filled with images the whole frame containing the grid of buttons shrinks and move to the center of the parent container frame
Thanks in advance