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

bindings in Tkinter

I made a "notebook" script in Python and bind CTRL+N as next file. At
the first time it works well, but then it stops. I found, that I have to
release CTRL, when using this second time. Is there any solution so I do
not have to release CTRL and just keep pressing N,N,N,....

Thanks a lot
Pavel

Using Python 2.3 under W2k.
Jul 18 '05 #1
3 2140
The following program just fine for me, printing "Control-N"
multiple times without the need to release and re-press control each
time:
from Tkinter import Tk
t = Tk()
def puts(s): print s
t.bind("<Key-Control_L>", lambda e: puts("Control"))
t.bind("<Key-Control_R>", lambda e: puts("Control"))
t.bind("<KeyRelease-Control_L>", lambda e: puts("Released Control"))
t.bind("<KeyRelease-Control_R>", lambda e: puts("Released Control"))
t.bind("<Control-n>", lambda e: puts("Control-N"))
t.mainloop()

Your problem must be because you've done something more complicated than
you've told us. For instance, if your binding for <Control-n> creates
or destroys widgets, moves the input focus, etc., maybe something bad is
happening.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAzam6Jd01MZaTXX0RAp6uAJ9iGCEk6rcOv7OWJip71C kEZg7JoACgrMwp
fHtcrQazgmh+2UNTsmMPvxk=
=IkkD
-----END PGP SIGNATURE-----

Jul 18 '05 #2
Solved.- I must have old documentation, I used '<Control_L>n'.
Thank you.
Pavel

Jeff Epler napsal(a):
The following program just fine for me, printing "Control-N"
multiple times without the need to release and re-press control each
time:
from Tkinter import Tk
t = Tk()
def puts(s): print s
t.bind("<Key-Control_L>", lambda e: puts("Control"))
t.bind("<Key-Control_R>", lambda e: puts("Control"))
t.bind("<KeyRelease-Control_L>", lambda e: puts("Released Control"))
t.bind("<KeyRelease-Control_R>", lambda e: puts("Released Control"))
t.bind("<Control-n>", lambda e: puts("Control-N"))
t.mainloop()

Your problem must be because you've done something more complicated than
you've told us. For instance, if your binding for <Control-n> creates
or destroys widgets, moves the input focus, etc., maybe something bad is
happening.

Jeff

Jul 18 '05 #3
On Wed, Jun 16, 2004 at 06:58:37AM +0200, p.kosina wrote:
Solved.- I must have old documentation, I used '<Control_L>n'.
Thank you.
Pavel


Aha!

The first argument to bind can be a sequence of events, which would
explain exactly the behavior you saw. This *can* be useful (it's in
effect how double-click works) but it can also do something different
than what you want.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFA0D48Jd01MZaTXX0RAsX7AKCpc4kDteZdymyEjOGuTU 8Y5FbITACcCjj7
xXvwMsGBYpBc60Id5PGuutE=
=kOTv
-----END PGP SIGNATURE-----

Jul 18 '05 #4

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

Similar topics

1
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...
0
by: Will Woods | last post by:
Hi, I have installed readline on win32, and it works fine until I do: from Tkinter import * root = Tk() at which point the cursor keys stop working, and print strange characters. Any...
3
by: Gabriel B. | last post by:
I'm starting to write a POS application UI's module. There's no mouse, just a bunch of global shortcuts. the problem is that TK doesn't have global shortcuts! Is there a work-around or i will...
1
by: Arthur Chereau | last post by:
Hi, I'm trying to setup viewcvs to work with subversion 1.2.0 on Linux with Python 2.4.1. The last viewcvs (from CVS) needs subversion python bindings. I installed swig and built subversion from...
1
by: gjohannes | last post by:
Hi. I use Idle 1.1.1 on Python 2.4.1. The "Ctrl-" key bindings for indenting do not work on non-us keyboards where brackets are accessed by the "Alt Gr" key. The Tab key seem to work for...
0
by: mg | last post by:
Hello, First, I installed Python on a traditionnal default linux-x86 platform (tk.h is located in /usr/include) and I did not meet any problem. I can write the following instruction without...
12
by: Thomas Bartkus | last post by:
Does anyone use emacs together with both WordStar key bindings and python mode? I'm afraid that Wordstar editing key commands are burned R/O into my knuckles! I would like to play with emacs...
1
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...
1
by: Jason Yamada-Hanff | last post by:
Hi all, I'm working on a project that would benefit very much from Python Freetype2 bindings (the Fonty Python project). I don't want to duplicate efforts and wrap the library again if we don't...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.