Question about Tkinter
Cameron Laird
claird at starbase.neosoft.com
Fri Aug 10 09:44:58 EDT 2001
In article <9l07a201rdj at enews4.newsguy.com>,
Alex Martelli <aleaxit at yahoo.com> wrote:
>"Benjamin Wu" <chase at gnuchina.org> wrote in message
>news:9l03s7$6q9f0$1 at ID-54723.news.dfncis.de...
>> When I use Tkinter, I met a question as following:
>> I create three buttons and thire callback function
>> is the same, how to know which button active callback
>> function when one of they pressed?
>>
>> Anyone can help me?
>
>Use different callables for the callbacks -- if it must be
>the same function, curry the function with different
>preset arguments -- see for example
>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549
>about how to do currying in Python.
.
.
.
Good reference. Note that, in practice, it's entirely
natural to define a tiny factory method which ensures
the correspondence between, for example, button and data.
In the recipe above, factor out the data 'A'.
Confession time: in principle, GUI coders also can code
their own bindings and use %W substitution to compute
the widget which received the event. Does that work in
Tkinter? I've never used it, I can't find it documented,
and I'm already late for a meeting so can't experiment
myself just now. Fredrik, do the %-s work right?
Even if they do, I'd still curry.
--
Cameron Laird <claird at NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
More information about the Python-list
mailing list