473,770 Members | 6,322 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 3009
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
5984
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
7035
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
11907
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
7466
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
3598
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
9591
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
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10001
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,...
1
7415
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...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
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
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.