I'm using a listbox (with scrollbar) for logging:
self.listbox_log = Tkinter.Listbox(root, height = 5, width = 0,)
self.scrollbar_log = Tkinter.Scrollbar(root,)
self.listbox_log.configure(yscrollcommand = self.scrollbar_log.set)
self.scrollbar_log.configure(command = self.listbox_log.yview)
Now, when I do:
self.listbox_log.insert(END,str)
I want the inserted element to be selected. I've tried:
self.listbox_log.selection_anchor(END)
but that doesn't work... Please suggest a solution...
try to do it in this way. (I have copied from another question: How to auto-scroll a gtk.scrolledwindow?) It works fine for me.
AFAIK the ScrollBar widget doesn't have an auto-scroll feature, but it can be easily implemented by calling the
listBox
'syview()
method after you insert a new item. If you need the new item to be selected then you can do that manually too using thelistbox
'sselect_set
method.