Python Tkinter Text Area set cursor to end

后端 未结 1 1774
长发绾君心
长发绾君心 2021-01-19 23:45

I have a Tkinter Text() object and I append lines to it using .insert(END, string). When the text fills the available area, I\'d expect it to scrol

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 23:59

    As usual with Tkinter, there are a number of ways to do this, but one is the easiest: Text.see:

    text.insert(END, "spam\n")
    text.see(END)
    

    If you want to make sure the start of the new text is visible, not the end of it, or if you only want to do this if the end was already visible beforehand or if the text is active, etc., you may need to look at the other options: scan_mark/scan_dragto, or yview and friends.

    0 讨论(0)
提交回复
热议问题