[Tutor] Update a button content on click

ALAN GAULD alan.gauld at btinternet.com
Tue Feb 15 17:56:46 CET 2011


> b1=button(root,image=None,height=4,width=4,command=ok)

This says you want the button to e 4 pixels squarte. Is that really 
what you want?, because....

and then ok defination is as follows :
> def ok():
>  b1["image"]=photo
>
>
>now problem is that after clicking on the button, image is coming 
>up like a flash and then button becomes almost to zero size. 
>
>
Like to 4x4 pixels maybe, just as you asked?
What happens if you change the size to something like 40x40?

Also in Tkinter to display an image you usually have to firtst create 
a PhotoImage object and assign that to the image attribute. It's not 
clear from your code whether you are doing that or not.
Is photo a PhotImage object?


I want to retain the height=4,width=4 along with the image after 
>clicking on the button. Image size is smaller than the button size.
>It sounds like your original size is greater than 4x4 and after setting 
the image it shrinks to 4x4...


HTH,

Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110215/4f47a835/attachment.html>


More information about the Tutor mailing list