473,386 Members | 1,801 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,386 software developers and data experts.

(Tkinter) Can I bind a key to Canvas?

Hi all,

I have a canvas and a rectangle draw on it. Can I bind a key(e.g. UP)
to the canvas and make the rectangle move up? Or shall I bind the key
to rectangle(I don't think so, because it is not a widget)?

Any suggestions are welcome!
Best regards,
Davy
Nov 21 '07 #1
1 2593
I have tried key and mouse click (when receive a event, print some
diagnose information ). I found mouse click work well in canvas but
key not work well.

It seems canvas cannot get key event?

self.canv.bind('<Up>',self._onUpKey) ## don't work
self.canv.bind('<Button-1>', self._onClick) ## work

Any suggestion?

Best regards,
Davy
Nov 21 '07 #2

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

Similar topics

2
by: mksql | last post by:
New to Tkinter. Initially, I had some code that was executing button commands at creation, rather than waiting for user action. Some research here gave me a solution, but I am not sure why the...
1
by: syed_saqib_ali | last post by:
Please take a look at and run the code snippet shown below. It creates a canvas with vertical & Horizontal scroll-bars. If you shrink the window to smaller than the area of the canvas, the...
0
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...
1
by: apriebe47 | last post by:
Hello, I have created a simple canvas in Tkinter to display a number of PhotoImages, I then bind a key (in my case, <Up>) to start a loop that plays through a list of PhotoImages to make it an...
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...
3
by: Gigs_ | last post by:
how to write text on canvas. i know that i need to use canvas.create_text, but how to write text than when i create_text? or how to access object ID in canvas and change some options? thanks...
4
by: Davy | last post by:
Hi all, I have written a simple Tkinter program, that is draw a rectangle in a canvas, when I press Up key, the rectangle move up. But the program seems work not properly? My environment is...
4
by: skanemupp | last post by:
mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of...
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...
3
by: skanemupp | last post by:
so i load a gif onto a canvas and when i click the canvs i want to get the color of the pixel that is clicked. so i need to ge the object im clicking. i was told in another thread to use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.