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_call back, "+")
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. 3 2762
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<lamb da>' t.bind("<<V>>", lambda evt: None, "+")
'136776692<lamb da>' t.bind("<<V>>")
'if {"[136008116<lambd a> %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T
%X %Y %D]" == "break"} break\n\nif {"[136776692<lambd a> %# %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
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_call back, "+")
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
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*********@N0 SP4M.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_call back, "+")
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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 error or X11 BadGC error on both Solaris (2.6 and
2.7) and Linux (Mandrake 8.0); it doesn't crash on Windows. I tried to simplify
the script, but I couldn't reproduce the crash with a simpler code. So the code
below is somewhat long; sorry for that.
...
|
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
|
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 somebody clue me in regarding how this is
done? Muchas gracias.
Peace
|
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 time that the
event binding of a double-click is quite long, on the order of a second
or so. I am double-clicking twice in a second, and the function is
being executed 3 times, and not just 2. I want to know, is this
controlled by the OS, or by...
| |
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 explicit
argument. For example, in Perl/Tk,
$widget->bind( Tk::Button )
returns a list like
<Key-Return>
|
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 script
that basically opens communication pipes with the three others. The idea
is that the fourth script works as a communication intermediary between
the others. The problem is that I can't make the Tkinter GUIs respond to
stdin events because the...
|
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 fact that the callbacks that might tell the
target that the mouse has entered it (<Enter>, <Any-Enter>,
even <Motion>) aren't called if the mouse's button is down.
What am I missing? Have I failed to find the right Tkinter
document? Is Tkinter...
|
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(), tkButtonLeave(),
tkButtonUp()
However, they are not working, when you try, you will get:
_tkinter.TclError: invalid command name "tkButtonLeave"
|
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...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |