473,404 Members | 2,170 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,404 software developers and data experts.

Retrieving event descriptors in Tkinter

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>
<Key-space>
<ButtonRelease-1>
....

Is it possible to do the same in Tkinter? I have looked through
Fredrik Lundh's on-line reference and also the one by John Shipman. I
am unable to locate the function I need. Perhaps I have not looked hard
enough. Any help would be much appreciated.

Thanks.

Avi Kak
ka*@purdue.edu

May 8 '06 #1
2 1437
Avi Kak wrote:
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>
<Key-space>
<ButtonRelease-1>
....

Is it possible to do the same in Tkinter? I have looked through
Fredrik Lundh's on-line reference and also the one by John Shipman. I
am unable to locate the function I need. Perhaps I have not looked hard
enough. Any help would be much appreciated.


Tkinter matches Tk quite closely, and there's no way to get *all* bindings
for a standard widget with a single call at the Tk level (afaik).

to extract the same information from a Tkinter widget, you should first call
bindtags() on the widget to get a list of binding classes used for this widget,
and you can then use bind_class(cls) to get the events for that class.

to get all events, you can use something like:
bindings = set()
for cls in b.bindtags(): .... bindings |= set(b.bind_class(cls))
.... bindings

set(['<Alt-KeyRelease>', '<Leave>', '<Enter>', '<KeyRelease-Alt_L>',
'<Key-Alt_R>', '<<PrevWindow>>', '<Key-F10>', '<KeyRelease-F10>',
'<Key-space>', '<Alt-Key>', '<Button-1>', '<ButtonRelease-1>',
'<KeyRelease-Alt_R>', '<Key-Tab>', '<Key-Alt_L>'])

</F>

May 8 '06 #2
Thanks very much. That's exactly what I was looking for. --- Avi

May 8 '06 #3

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

Similar topics

3
by: Ivan Letal | last post by:
I have just tried this code.. Tkinter import * root = Tk() def callback(event): print "clicked at", event.x, event.y frame = Frame(root, width=100, height=100)
4
by: Christopher Subich | last post by:
I'm building an application involving both twisted and Tkinter. Since twisted co-opts <widget>.mainloop() in its reactor.run(), and since it behaves very badly if the application quits without...
0
by: WaterWalk | last post by:
Hello. When I tried to make Tkinter canvas widget respond to MouseWheel event on Windows XP, I failed. The canvas just doesn't receive MouseWheel event. I used bind_all to find out which widget...
2
by: Kevin Walzer | last post by:
I'm trying to decide whether I need threads in my Tkinter application or not. My app is a front end to a command-line tool; it feeds commands to the command-line program, then reads its output and...
2
by: Kevin Walzer | last post by:
I'm porting a Tkinter application to wxPython and had a question about wxPython's event loop. The Tkinter app provides a GUI to a command-line tool. It gathers user input, and opens an...
0
by: John Stevens | last post by:
I am using PIL to make images that I need to display in a sequence. The image needs to change when a an event happens from a serial port. I call the following function to display the image, but...
4
by: skanemupp | last post by:
when calling function hmm here, what do i get? the widget i clicked on? if i have a canvs on wich i have a bitmap and i click on the bitmap, is the event.widget then the bitmap? can i get info...
1
by: Noah | last post by:
I'm trying to match against Event.type for KeyPress and ButtonPress. Currently I'm using integer constants (2 and 4). Are these constants defined anywhere? The docs talk about KeyPress and...
7
by: gordon | last post by:
is it possible to send a message to the gui instance while the Tk event loop is running?I mean after i create a gui object like root=Tk() mygui=SomeUI(root) and call root.mainloop() can i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.