Is there a way to make the textbox freeze its position as its updating?
I\'m making updating a textbox in TKinter every 1 second but to display some constantly changing
If you want the widget to automatically scroll to the end after inserting text, run the command self.output.see("end")
.
self.output.insert(END, text_str)
self.output.see("end")
If the goal isn't to stay at the bottom, but rather to keep the scrollbar where it is, you can query the scrollbar to find it's position and then attempt to reset it. This won't work perfectly if the new data has more or fewer lines than the current data, but there's simply no avoiding that.
For example:
def click2(self):
# get the current position of the text
yview = self.output.yview()
...
self.output.insert(END, text_str)
self.output.yview_moveto(yview[0])
self.root.after(1000, self.click2)