473,511 Members | 12,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

tkinter text <Key> event

Jay
I'm having trouble with using the <Keyevent with the Text object.
When I use them together (which is a logical combination), I use this
code:

textbox = Text(root, wrap="word", height=15, width=50)
textbox.bind("<Key>", resolveGlyphs)

def resolveGlyphs(event):
textBuf = textbox.get(1.0, END)
print(textBuf)

What it prints out for me is everything except for the last character
-- the one that triggered the event. How can I get the entire
contents?

I apologize if this has already been discussed. I searched and
couldn't find it.

Sep 7 '06 #1
3 2100
On Wed, 2006-09-06 at 17:54 -0700, Jay wrote:
I'm having trouble with using the <Keyevent with the Text object.
When I use them together (which is a logical combination), I use this
code:

textbox = Text(root, wrap="word", height=15, width=50)
textbox.bind("<Key>", resolveGlyphs)

def resolveGlyphs(event):
textBuf = textbox.get(1.0, END)
print(textBuf)

What it prints out for me is everything except for the last character
-- the one that triggered the event. How can I get the entire
contents?
bind the textbox to the <KeyReleaseevent because by then it has been
drawn on the Text widget. The <Keyevent is equivalent to the
<KeyPressevent

Regards,

John

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Sep 7 '06 #2
Jay
That makes sense, but it's not working.
John McMonagle wrote:
On Wed, 2006-09-06 at 17:54 -0700, Jay wrote:
I'm having trouble with using the <Keyevent with the Text object.
When I use them together (which is a logical combination), I use this
code:

textbox = Text(root, wrap="word", height=15, width=50)
textbox.bind("<Key>", resolveGlyphs)

def resolveGlyphs(event):
textBuf = textbox.get(1.0, END)
print(textBuf)

What it prints out for me is everything except for the last character
-- the one that triggered the event. How can I get the entire
contents?

bind the textbox to the <KeyReleaseevent because by then it has been
drawn on the Text widget. The <Keyevent is equivalent to the
<KeyPressevent

Regards,

John

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Sep 8 '06 #3
Jay
Nevermind. It works. Sorry. I got my files mixed up! :-)
John McMonagle wrote:
On Wed, 2006-09-06 at 17:54 -0700, Jay wrote:
I'm having trouble with using the <Keyevent with the Text object.
When I use them together (which is a logical combination), I use this
code:

textbox = Text(root, wrap="word", height=15, width=50)
textbox.bind("<Key>", resolveGlyphs)

def resolveGlyphs(event):
textBuf = textbox.get(1.0, END)
print(textBuf)

What it prints out for me is everything except for the last character
-- the one that triggered the event. How can I get the entire
contents?

bind the textbox to the <KeyReleaseevent because by then it has been
drawn on the Text widget. The <Keyevent is equivalent to the
<KeyPressevent

Regards,

John

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Sep 8 '06 #4

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

Similar topics

0
3586
by: wang xiaoyu | last post by:
Hello,everyone. my program runs well in windows,i use tkSimpleDialog to receive some input,but when i copy my program into Linux RH8.0,entrys in my tkSimpleDialog derived Dialog have a vital...
1
4047
by: Raghul | last post by:
hi, I am developing a jabber client.What I need is whrn i enter text in the text area and when I press return key. The following text should be send.I found the way to send the message, the only...
0
1787
by: Markus Seibold | last post by:
Hello NG, sorry for pasting that much code but I just can't figure out how get the <key><keyref> to work in XML Schema. I am using XMLSpy 4.3 for editing my XML. I want to represent a...
1
2272
by: I am dog | last post by:
Hi , I use VS 2005 beta1 to do some thing as follows. declare a Dictionary<ulong,DelegateTyep> dictionary = new ... and use dictionary object such as dictionary += aDelegateTyepObject;
1
2330
by: Keith | last post by:
Hi, I created a dataset during run time and assigned it to the datagrid. But i cant get the FindBy<Key> method to work. During design time, i got a error "dtProdHdr is not a member of...
0
1033
by: KatB | last post by:
I have an aspx page with a button on it (Button1), and a ascx control with a text field and a button (Button2). When I click Button2, Button1 fires. Since ascx doesn't allow <form> tags, I can't...
1
1289
pankajkmeena
by: pankajkmeena | last post by:
is it possible to capture control+alt+<any key> in PHP
6
3545
pankajkmeena
by: pankajkmeena | last post by:
is it possible to capture control+alt+<any key> in javascript
10
1591
dmjpro
by: dmjpro | last post by:
Actually what i am trying to do that is to search some data as per users' entries. Firstly i am fetching the whole data from the database and keeping in a hidden table then as user gives the search...
0
7251
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
7367
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
7430
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...
1
7089
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
7517
tracyyun
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...
0
5673
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,...
1
5072
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...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.