473,408 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Tkinter binding list

Hi,

I have a weird need in tkinter. If I have a widget I can *set* a binding

..bind("<the event>", the_callback)
I also can *append* a binding

..bind("<the event>", the_second_callback, "+")

but now, I need to *replace* a callback. The easier way is to obtain the
bindings, delete them all, and rebind the new list.

So, how can I replace a callback, when there are more than one binding ?
or, as an equivalente question,

how can I obtain the list of callbacks binded to widget event ?

Thanks,
RodrigoB.

Jul 18 '05 #1
3 2735
The bind method with one argument returns the string of tcl code that is
the current binding. For instance:
t = Tkinter.Tk()
t.bind("<<V>>", lambda evt: None) '136008116<lambda>' t.bind("<<V>>", lambda evt: None, "+") '136776692<lambda>' t.bind("<<V>>") 'if {"[136008116<lambda> %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T
%X %Y %D]" == "break"} break\n\nif {"[136776692<lambda> %# %b %f %h %k
%s %t %w %x %y %A %E %K %N %W %T %X %Y %D]" == "break"} break\n'
The bind method with zero arguments returns all the existing bindings: t.bind()

('<<V>>',)

Jeff

Jul 18 '05 #2
Rodrigo Benenson wrote:
Hi,

I have a weird need in tkinter. If I have a widget I can *set* a binding

.bind("<the event>", the_callback)
I also can *append* a binding

.bind("<the event>", the_second_callback, "+")

but now, I need to *replace* a callback.


What's the difference between "setting" and "replacing" for you? If you set a
callback doing a "return 'break'" at the end, the event should execute your
binding and nothing else. Can you post a script showing exactly what you want to
do and what problems you have?
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Jul 18 '05 #3
I mean replacing *one* of the callbacks for the event. Suposing that I do
not know which callbacks were previously set, except the one I want
remplace. If I *set* a callback, all the callback list will be erased.

This is a case in a plugin system. My plugin want to add a hook, but is
probable that other plugins already hooked they own callbacks. I do no want
to delete they callbacks but just to remplace the "root" callback (for which
I already have a reference).

I did this post because I found strange to do not found a way to do this,
maybe it should be a PEP for Tkinter ?

RodrigoB.

"Eric Brunel" <er*********@N0SP4M.com> escribió en el mensaje
news:br**********@news-reader5.wanadoo.fr...
Rodrigo Benenson wrote:
Hi,

I have a weird need in tkinter. If I have a widget I can *set* a binding

.bind("<the event>", the_callback)
I also can *append* a binding

.bind("<the event>", the_second_callback, "+")

but now, I need to *replace* a callback.
What's the difference between "setting" and "replacing" for you? If you

set a callback doing a "return 'break'" at the end, the event should execute your binding and nothing else. Can you post a script showing exactly what you want to do and what problems you have?
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Jul 18 '05 #4

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

Similar topics

3
by: Ton K. | last post by:
Folks, I get subject when binding <Button-1> to a listbox. The value for h is '??' which triggers the error. I'm running Python 2.2.2 from SuSE. Please help TK
8
by: Eric Brunel | last post by:
Hi all, I was creating a Tkinter widget in the style of the reversed tabs below Excel worksheets and I stepped in a serious problem: the code I made makes python crash with a seg fault, bus...
7
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...
6
by: Elaine Jackson | last post by:
I've got a script where a button gets pushed over and over: to cut down on the carpal tunnel syndrome I'd like to have the button respond to presses of the Enter key as well as mouse clicks; can...
1
by: Tuvas | last post by:
I am trying to execute a function with a tkinter event binding double click. With 2 mouse clicks done quickly, the function should happen, otherwise, it should not. However, I am noticing that the...
2
by: Avi Kak | last post by:
Does Tkinter provide a function that returns all the event descriptors for a given widget class? I am looking for something similar to what you get in Perl/Tk when you call bind() with a single...
0
by: Diogo Bastos | last post by:
Hello, I'm fairly used to working with Python but it's the first time I'm trying to use Tkinter so I'm running into a problem. I'm using three python scripts with Tkinter GUIs and a fourth...
7
by: Peter Pearson | last post by:
Tkinter makes it very easy to drag jpeg images around on a canvas, but I would like to have a "target" change color when the cursor dragging an image passes over it. I seem to be blocked by the...
8
by: akineko | last post by:
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(),...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.