Set cursor position in a Text widget

前端 未结 3 1943
独厮守ぢ
独厮守ぢ 2020-12-31 16:28

Is it possible to set the cursor position in a Tkinter Text widget? I\'m not finding anything terribly useful yet.

The best I\'ve been able to do is emit a <

3条回答
  •  隐瞒了意图╮
    2020-12-31 16:53

    If "text", "line", and "column" are your text object, the desired text line and desired column variables are, respectively:

    text.mark_set("insert", "%d.%d" % (line + 1, column + 1))
    

    If you would not like to care about the line number... well, you have to.

    Complete documentation at: http://effbot.org/tkinterbook/text.htm

提交回复
热议问题