Callback functions arguments

ast nomail at invalid.com
Mon Oct 27 04:16:26 EDT 2014


Hi

In this web site at example n°5
http://fsincere.free.fr/isn/python/cours_python_tkinter.php

A program is using the "Scale" widget from tkinter module.
Here is a piece of code:

Valeur = StringVar()

echelle = Scale(Mafenetre, from_=-100, to=100, resolution=10, \
orient=HORIZONTAL, length=300, width=20, label="Offset", \
tickinterval=20, variable=Valeur, command=maj)

The "maj" callback function is:

def maj(nouvelleValeur):
    print(nouvelleValeur)

When the user move the scale with the mouse, the new position
is supposed to be printed on the python shell.

The "maj" function has an argument "nouvelleValeur" but no
argument is passed through the Scale widget.

So how the hell Python knows that it has to pass parameter
"Valeur" to the "maj" function ?

thx




More information about the Python-list mailing list