Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current cursor position for Text widget

I am using an onscreen keyboard to type data for a tkinter based gui.
I was able to use the entry field to enter, edit data through the onscreen keyboard such as getting current cursor position and length of the string.

temp = self.entry_label.get()
length_string=len(temp)
cursor_position = self.entry_label.index(INSERT)

But I wish to do the same for a Text widget. I could get the text for Text widget using get() method and its length but cannot get the current mouse cursor position.

temp=self.new_text.get(1.0, END)
cursor_position = self.new_text.index(INSERT)

Acutally it works and i am able to add character to that poisition , but after adding character cursor goes back to origional position , i.e last character

like image 797
Deepworks Avatar asked May 02 '15 08:05

Deepworks


1 Answers

maybe This works? Else maybe text_widget.index(Tkinter.INSERT) is what should work.

like image 175
nephthyes white Avatar answered Nov 04 '22 07:11

nephthyes white