473,785 Members | 2,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tkinter: tkButtonDown, tkButtonEnter, tkButtonInvoke, tkButtonLeave,t kButtonUp

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.TclErr or: invalid command name "tkButtonLe ave"

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(s elf, *dummy):
self.tk.call('t kButtonLeave', 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::unsupport ed {

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

variable PrivateCommands
array set PrivateCommands {
tkButtonAutoInv oke ::tk::ButtonAut oInvoke
tkButtonDown ::tk::ButtonDow n
tkButtonEnter ::tk::ButtonEnt er
tkButtonInvoke ::tk::ButtonInv oke
tkButtonLeave ::tk::ButtonLea ve
tkButtonUp ::tk::ButtonUp
.... snip ...

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

I placed the following into my Tkinter code and it worked.
self.btn.tk.cal l('::tk::Button Leave', 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-
Sep 1 '08 #1
8 3011
On Mon, Sep 1, 2008 at 7:45 PM, akineko <ak*****@gmail. comwrote:
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.TclErr or: invalid command name "tkButtonLe ave"

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.
Are you trying to simulate clicks ? You should be doing it using
event_generate, more below.
So, I spent time to solve this.

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

Tkinter.py line 2005 of 3759
def tkButtonLeave(s elf, *dummy):
self.tk.call('t kButtonLeave', 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::unsupport ed {

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

variable PrivateCommands
array set PrivateCommands {
tkButtonAutoInv oke ::tk::ButtonAut oInvoke
tkButtonDown ::tk::ButtonDow n
tkButtonEnter ::tk::ButtonEnt er
tkButtonInvoke ::tk::ButtonInv oke
tkButtonLeave ::tk::ButtonLea ve
tkButtonUp ::tk::ButtonUp
... snip ...
You are looking at the wrong place, try looking at library/button.tcl
Now, why I said about using event_generate instead of calling those
methods yourself.. tk sets several bindings that varies between
platforms for all these things you are trying to do, and they end up
calling these commands you are trying to call yourself. So, for
instance, given that you have a button:

btn = Tkinter.Button( )

to get tk::ButtonEnter called, you should be doing:

btn.event_gener ate("<Enter>")

and this will work for other those other events too, Leave (Leave),
Button-1 (Down), ButtonRelease-1 (Up), space (Invoke). The remaining
one to talk about is this "ButtonAutoInvo ke", which I'm unsure if you
really need it, but, if you do, you could use btn.invoke() supposing
the button has an associated callback which will use "after" to
schedule another btn.invoke().
>
This seems suggesting that the Tkinter bindings are binding obsolete
tk methods.
And, the method should be called seems ::tk::ButtonLea ve, instead.

I placed the following into my Tkinter code and it worked.
self.btn.tk.cal l('::tk::Button Leave', 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.
You should expect them to be totally removed from Tkinter actually.
>
Best regards,
Aki-
--
http://mail.python.org/mailman/listinfo/python-list


--
-- Guilherme H. Polo Goncalves
Sep 2 '08 #2
On Sep 1, 5:52 pm, "Guilherme Polo" <ggp...@gmail.c omwrote:
Are you trying to simulate clicks ? You should be doing it using
event_generate, more below.
Actually, I was trying to implement a "sticky" button.
(Button Release is done later by another event)

I already tried event_generate.
It worked as far as I didn't touch other widgets.
But somehow it failed to work if event_generate is called after other
widgets are activated.
You should expect them to be totally removed from Tkinter actually.
Sad to hear that. Controlling the button behaviour explicitly may not
be a common thing to do but it is still necessary thing to do. But you
gave me enough insights.

Aki-
Sep 2 '08 #3
On Mon, Sep 1, 2008 at 10:09 PM, akineko <ak*****@gmail. comwrote:
On Sep 1, 5:52 pm, "Guilherme Polo" <ggp...@gmail.c omwrote:
>Are you trying to simulate clicks ? You should be doing it using
event_generate , more below.

Actually, I was trying to implement a "sticky" button.
(Button Release is done later by another event)

I already tried event_generate.
It worked as far as I didn't touch other widgets.
But somehow it failed to work if event_generate is called after other
widgets are activated.
>You should expect them to be totally removed from Tkinter actually.

Sad to hear that. Controlling the button behaviour explicitly may not
be a common thing to do but it is still necessary thing to do. But you
gave me enough insights.
This is an illusion you have, calling those methods are not the way
for explicitly controlling button's behavior, not more than generating
proper events. The explicit way is to not use a button, instead
(ab)use Canvas.
>
Aki-
--
http://mail.python.org/mailman/listinfo/python-list


--
-- Guilherme H. Polo Goncalves
Sep 2 '08 #4
On Sep 1, 6:34 pm, "Guilherme Polo" <ggp...@gmail.c omwrote:
This is an illusion you have, calling those methods are not the way
for explicitly controlling button's behavior, not more than generating
proper events. The explicit way is to not use a button, instead
(ab)use Canvas.
Some of my custom widgets used Canvas.
When I designed the "sticky" button widget, I briefly considered use
of Canvas but I rejected because the one I wanted is nothing but
Button (except "sticky" behaviour).
I understand that use of Canvas provides greater flexibility but I
felt it was over-kill.
Your insights are very helpful for me and other people when designing
a custom widget.

Aki-
Sep 2 '08 #5
On Mon, Sep 1, 2008 at 11:01 PM, akineko <ak*****@gmail. comwrote:
On Sep 1, 6:34 pm, "Guilherme Polo" <ggp...@gmail.c omwrote:
>This is an illusion you have, calling those methods are not the way
for explicitly controlling button's behavior, not more than generating
proper events. The explicit way is to not use a button, instead
(ab)use Canvas.

Some of my custom widgets used Canvas.
When I designed the "sticky" button widget, I briefly considered use
of Canvas but I rejected because the one I wanted is nothing but
Button (except "sticky" behaviour).
Can you clarify what is this "sticky" behavior ? Are you referring to
a toggle button ? If yes, then you might be after a simple
Checkbutton:

checkbutton = Tkinter.Checkbu tton(indicatoro n=False, text='test')
I understand that use of Canvas provides greater flexibility but I
felt it was over-kill.
Your insights are very helpful for me and other people when designing
a custom widget.

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


--
-- Guilherme H. Polo Goncalves
Sep 2 '08 #6
On Sep 1, 8:28 pm, "Guilherme Polo" <ggp...@gmail.c omwrote:
Can you clarify what is this "sticky" behavior ? Are you referring to
a toggle button ? If yes, then you might be after a simple
Checkbutton:

checkbutton = Tkinter.Checkbu tton(indicatoro n=False, text='test')
I wouldn't spend days to create a custom widget to mimick the
Checkbutton ;-)

I don't need to describe the detail but once the button was pressed
for a bit while, a command is sent through communication.
The button is left being ButtonDown ("sticky") until an
acknowledgement is sent back through communication.
This is a way to let the user know the action was acknowledged at
another end.

I think probably very few people needs such widget.

Aki-

Sep 2 '08 #7
On Tue, Sep 2, 2008 at 12:44 AM, akineko <ak*****@gmail. comwrote:
On Sep 1, 8:28 pm, "Guilherme Polo" <ggp...@gmail.c omwrote:
>Can you clarify what is this "sticky" behavior ? Are you referring to
a toggle button ? If yes, then you might be after a simple
Checkbutton:

checkbutton = Tkinter.Checkbu tton(indicatoro n=False, text='test')

I wouldn't spend days to create a custom widget to mimick the
Checkbutton ;-)

I don't need to describe the detail but once the button was pressed
for a bit while, a command is sent through communication.
The button is left being ButtonDown ("sticky") until an
acknowledgement is sent back through communication.
This is a way to let the user know the action was acknowledged at
another end.

I think probably very few people needs such widget.
Did you even try creating a checkbutton with indicatoron=Fal se ? You
could get surprised.
>
Aki-

--
http://mail.python.org/mailman/listinfo/python-list


--
-- Guilherme H. Polo Goncalves
Sep 2 '08 #8
On Sep 2, 5:46 am, "Guilherme Polo" <ggp...@gmail.c omwrote:
Did you even try creating a checkbutton with indicatoron=Fal se ? You
could get surprised.
I didn't. My perception of checkbutton was a button with a check.
So, I tried as you suggested.
Yes, you are right. It is almost what I wanted (sticky behaviour).
By ignoring the ButtonRelease and Leave events, yes, it can perfectly
meet my requirements.
As checkbutton has deselect() method, this is a better approach, I
have to admit.

Thank you for showing me the correct way to implement.

Aki-
Sep 2 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5986
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu bar at the top and a grid of colored rectangles filling the remainder of the window. Mind you, this is a contrived test application to help me understand Tkinter and Python, not an actual application yet. I've trivially subclassed Tkinter.Canvas into ColorCanvas, added a bunch of ColorCanvases...
3
7036
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter import * class App:
2
3250
by: Paul A. Wilson | last post by:
I'm new to Tkinter programming and am having trouble creating a reusable button bar... I want to be able to feed my class a dictionary of button names and function names, which the class will make. My button bar is implemented a Frame subclass, which takes the button dictionary as an argument and displays the buttons on the screen: class OptionsBar(Frame): def __init__(self, buttonDict, parent=None) Frame.__init__(self, parent)
7
11908
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of wxPython. Mitchell Timin -- "Many are stubborn in pursuit of the path they have chosen, few in
2
7472
by: codecraig | last post by:
Hi, I was reading through the Tkinter tutorial at http://www.pythonware.com/library/tkinter/introduction/index.htm ...and it mentions that by doing, from Tkinter import * you have access to the constants in Tkconstants, since Tkinter imports it automatically.
0
3587
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust accordingly. However, what I really want to happen is that the area of the canvas that the scrollbars show (the Scrollregion) should expand as the window grows. It doesn't currently do this. although, if the window shrinks smaller than the...
1
3600
by: Michael Yanowitz | last post by:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that I am hoping someone knows what I am doing wrong: 1) Pressing the Settings.. Button multiple times, brings up many instances of the Settings Panel. I just want it to bring up one. Is there an easy way to do that?
8
3288
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to my pc. But, it is not getting installed and is failing by throwing the below errors. Should i need to configure / install any specific files for resolving this issue ?
3
2983
by: joshdw4 | last post by:
I hate to do this, but I've thoroughly exhausted google search. Yes, it's that pesky root window and I have tried withdraw to no avail. I'm assuming this is because of the methods I'm using. I guess my question is two-fold. 1) How do I get rid of that window? 2) Any comments in general? I am just learning python (and coding with classes), so I'm sure there are things I should pound into my head before I learn bad habits. Here's the...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.