Hi everyone,

This is a memorandum so that other people can share the info.

The following methods are declared in the Tkinter Button class.
tkButtonDown(), tkButtonEnter(), tkButtonInvoke(), tkButtonLeave(),
tkButtonUp()
However, they are not working, when you try, you will get:

_tkinter.TclError: invalid command name "tkButtonLeave"

The bindings in the Tkinter are mapping them to non-existing tk
methods.
I needed to use the method badly and I couldn't find any clear
solution for this. So, I spent time to solve this.

tkButtonLeave(), for example, is declared as follows:

Tkinter.py line 2005 of 3759
    def tkButtonLeave(self, *dummy):
        self.tk.call('tkButtonLeave', self._w)

Now, in the Tk source distribution, I found the following:
unsupported.tcl
# Commands provided by Tk without official support.  Use them at your
# own risk.  They may change or go away without notice.

namespace eval ::tk::unsupported {

    # Map from the old global names of Tk private commands to their
    # new namespace-encapsulated names.

    variable PrivateCommands
    array set PrivateCommands {
    tkButtonAutoInvoke      ::tk::ButtonAutoInvoke
    tkButtonDown            ::tk::ButtonDown
    tkButtonEnter           ::tk::ButtonEnter
    tkButtonInvoke          ::tk::ButtonInvoke
    tkButtonLeave           ::tk::ButtonLeave
    tkButtonUp          ::tk::ButtonUp
... snip ...

This seems suggesting that the Tkinter bindings are binding obsolete
tk methods.
And, the method should be called seems ::tk::ButtonLeave, instead.

I placed the following into my Tkinter code and it worked.
    self.btn.tk.call('::tk::ButtonLeave', self.btn._w)

//
Summary:
(1) tkButtonDown, tkButtonEnter, tkButtonInvoke, tkButtonLeave,
tkButtonUp are not working.
(2) Bindings are not correct
(2) Workaround is call correct tk methods directly

I hope future Tkinter will be corrected so that the methods are
available as documented.

Best regards,
Aki-
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to