List Info

Thread: Tkinter-Button class




Tkinter-Button class
country flaguser name
Malaysia
2007-03-19 00:41:01
Hi,

Thanks for the help guys.


I have tried gui programming using Tkinter and use the Button class which accepts the command argument which is a function object.

The question is how to send arguments if the function accepts arguments.





Get your own web address.
Have a HUGE year through Yahoo! Small Business.
Re: Tkinter-Button class
country flaguser name
United States
2007-03-19 05:19:44
ammar azif wrote:
> Hi,
> 
> Thanks for the help guys.
> 
> 
> I have tried gui programming using Tkinter and use the
Button class 
> which accepts the command argument which is a function
object.
> 
> The question is how to send arguments if the function
accepts arguments.

A common way to do this is to use a lambda expression to
bind the 
arguments, e.g.
Button(..., command = lambda: func_with_args(1, 2, 3))

For example see
http://ww
w.daniweb.com/code/snippet610.html

You could also define explicit, short helper functions if
you don't want 
to use lambdas.

Kent
_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )