Hello everybody,
I'm trying to write a program with automatic completion in
GtkEntries,so I wrote a signal handler for the signal "insert_text"
def on_txt_changed(widget, input, length, pos):
list = ["xyz","abc","def"]
# We concatenate the last character entered by the user with
# the beginning of the text.
input = input[:length]
position = widget.get_position() + 1
to_complete = widget.get_text()[:position]
to_complete = "%s%c" % (to_complete[0:position-1], input)
# We look for the text in the list
for text in list:
index = string.find(text,to_complete)
if index == 0: # We have found the right text
widget.signal_handler_block(signal_id)
widget.set_text( auteur )
widget.signal_handler_unblock(signal_id)
widget.emit_stop_by_name("insert_text")
break
But the cursor is always before the first character of the entry, and
I'd like to move it after what the user typed. Example :
the user type "a", so the text is completed as "abc" and I'd like the
cursor to be after the "a" rather than at the beginning.
I tried with widget.set_position() but it doesn't work.
I also wonder what to do with the last parameter of the handler "pos"
which is a PyCObject, translated in C by a gint *.
By the way, I am a beginner at both Python and Gnome/Gtk+ !
Thanks,
Stephane
--
St�phane Leibovitsch
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk