[Tutor] Update a button content on click

ANKUR AGGARWAL coolankur2006 at gmail.com
Tue Feb 15 17:28:10 CET 2011


hmmm... i got the point.
I applied it in image case.

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

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. 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.

On Tue, Feb 15, 2011 at 5:58 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

>
> "ANKUR AGGARWAL" <coolankur2006 at gmail.com> wrote
>
>
>  I am looking for a method using Tkinter module to update the button on the
>> click.
>>
>
> Define an event handler command for the button.
> Lets call it sayHi()
>
> def sayHi(self):
>    self.myButton['text'] = 'hi'
>    # Note:event handlers don't return results so store it as an attribute
>    self.myButtonResult = 'hi'
>
> Now create the widget with spam as the handler.
>
> self.myButton = Button(parent, text='hello', command = spam)
>
> That's it.
>
>
>  the its click should be "hi". I tried it through event handling but failed
>> to do so.
>>
>
> It would be more helpful if you posted the code that you tried
> and a more detailed explanation of "failed to do so".
> What happened? Did it update but not store a value?
> Did you get an error message? Did anything happen?
>
> The more specific information you provide the more likely you
> are to get a specific solution that works.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110215/490becd9/attachment.html>


More information about the Tutor mailing list