Lambda returning tuple question, multi-expression
Thomas Passin
list1 at tompassin.net
Thu Mar 9 00:13:00 EST 2023
On 3/8/2023 11:19 PM, aapost wrote:
> In both cases (as per my intent)
Well, that's the trouble. You haven't stated your intent, so we're
forced to try to reverse engineer it. Below I state what my
reverse-engineering effort thinks is your intent. It would be better if
you actually said clearly what you want to achieve.
> So as far as the examples given above (which I can't really parse), if
> you meant for passing in a bool value, to do so would require something
> like:
>
> b.config(command=lambda enabled: config_b_and_entries(enabled))
As best as I can understand what you are trying to do here, it seems
like you want to enable/disable those Entry widgets when you configure
the b widget to be enabled/disabled. That way their states would all
track each other, with only a single command needing to be issued.
That seems like a sensible goal. The function config_b_and_entries()
that I suggested is not meant to be the target of a lambda expression
that is the argument of b.config(). It is meant to be called *instead*
of b.config(command = lambda.....). I can't see any benefit of trying
to force this coordination of states by using an obscure lambda
expression when you can achieve the same result with a straightforward,
easy to read function or method call.
OTOH, if you are not trying to achieve this coordination of states, then
what are you trying to do? Don't go making us guess any more.
More information about the Python-list
mailing list