[Tutor] Help me understand this tkinter related code

Alan Gauld alan.gauld at btinternet.com
Fri Feb 26 21:22:17 CET 2010

Please don't hijack an old message to create a new subject.
Those of us using threaded readers might not see it and you
lose potential answers.

"Robert DeLaurentis" <lists at bobdel.com> wrote

> The local function change_volume(v) requires the argument v to operate 
> properly,
> but I'm unclear where the value of that argument is being set or why the 
> code fails
> without it.

> def change_volume(v):
>    track.set_volume(volume.get())
> volume_scale = Scale(app,
>                        variable     = volume,
>                        from_        = 0.0,
>                        to           = 1.0,
>                        resolution   = 0.1,
>                        command      = change_volume,
>                        label        = "Volume",
>                        orient       = HORIZONTAL)

I'm not familiar with the wodget in question but it looks like the command 
expects to pass a parameter to the callback function. Therefore the 
function needs
to provide a placeholder even though it doesn't use it!

You would need to find the documentation for the widget to confirm that 

A Google seartch threw up this:


Which seems to confirm my theory :-)

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list