How to use tk.call ?
Eric Brunel
eric_brunel at despammed.com
Tue May 30 03:25:11 EDT 2006
On 29 May 2006 21:13:07 -0700, <jerry.levan at gmail.com> wrote:
>>> self.table.bind("<Button-4>",self.table.tk.call(self.table._w,'yview','scroll',-5,'units')
>
>> I haven't used Table, but are you sure that what you are calling
>> "self.table" here actually has mouse focus?
>
>> James
>
> Yup, I click on the table, and then frantically work the mouse wheel to
> no
> effect...
... which is quite normal, since you actually didn't define any binding.
What you did is:
- *Call* self.table.tk.call(self.table._w,'yview','scroll',-5,'units'),
which did the scroll;
- Pass the *result* of this call (which is probably None or the empty
string) as the second parameter of self.table.bind.
So no binding was defined.
One solution is to define the binding via a lambda, like this (untested):
self.table.bind("<Button-4>", lambda e, t=self.table: t.tk.call(t._w,
'yview', 'scroll', -5, 'units'))
For more information on lambda, see here:
http://docs.python.org/tut/node6.html#SECTION006750000000000000000
HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
More information about the Python-list
mailing list