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

Tkinter - incremental input ?

Hi,

I don't want to reinvent the wheel but I cannot find it so far.

Many editors have a so-called incremental search feature.
As you type characters, elements of a set of strings which fit so far are
displayed or at least, the first one of these is displayed.

Now I want to do something similar in Tkinter - an Entry widget
which displays possible 'completions'
e.g. given the list of names (...,'Hardy','Helmut',..)

As soon as enter the character 'H' the string 'Hardy'
would be displayed in the Entry widget - but the cursor
is still at position 2 (given 'H' is a position 1)
Furthermore, as soon as I enter 'e', it would change the
text to 'Helmut', and so on.

While I can bind '<Key>' to a callback, I haven't figured out how
to get (and later on set) the cursor within the Entry widget.
In other words I need to know at which character position the last
character was entered.
Currently I can only see the brute force method: keeping track of
all cursor positioning means like <Backspace>, <Del>, the '<-' and '->' keys
and mouse clicks.
Is there an easier method?

Many thanks for a hint or even a pointer to an example,
Helmut.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jan 30 '08 #1
1 2137
On Wed, 30 Jan 2008 13:32:00 +0100, Helmut Jarausch
<ja******@igpm.rwth-aachen.dewrote:
[snip]
While I can bind '<Key>' to a callback, I haven't figured out how
to get (and later on set) the cursor within the Entry widget.
In other words I need to know at which character position the last
character was entered.
You can get the position of the insertion point with
entry.index('insert'), and set it via entry.icursor(index). If you want to
do this as the user types, take care to bind to KeyRelease; this way, the
character corresponding to the key has already been entered in the entry.

BTW, you may also want to automatically select the part that the user
hasn't actually typed. This can be done with entry.selection_clear(), then
entry.selection_range(start_position, end_position).

HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
Jan 30 '08 #2

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

Similar topics

5
by: Otto Krüse | last post by:
Hi everyone, I'm building a GUI in which I want, amongst other things, for people to fill in there postal code. The postal codes of my country (Holland) are in this format: 1234 AB So for the...
5
by: Ali | last post by:
I was wondering how one would go about displaying unicode in a Label object in a Tkinter window. I am trying to display text in another language. Please help.
0
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...
0
by: Bob Greschke | last post by:
I want to create a search function on a Text() widget full of text like the incremental search in emacs -- if you type an "f" emacs goes to the first "f", type another "f" and it goes to the first...
1
yabansu
by: yabansu | last post by:
Hi all, I implemented a basic client application. It communicates with server and works properly. Building processes succeed just by giving the following warning: LINK : D:\DOC\Visual Studio...
1
by: vigacmoe | last post by:
Hi all, I'm trying to write a simple tkinter program, then this problem popped up. The followin code will describe the problem. ------------------------------------------ import Tkinter ...
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...
8
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to...
0
by: nbardach | last post by:
Hope this finds everyone well. Happy New Year! I'm trying to build a Loop for a set of dropdown menus I'm inserting into a form. Basically, the client has to be able to select 1 to 20 donors...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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.