Is there a way to preselect/highlight a listbox item with the Tkinter GUI toolkit at the startup of the program without clicking the mouse on it?

Listbox.activate(n) selects line number n graphically and also adds it to Listbox.curselection()

Jeff

Sorry Jeff, this does not seem to highlight or select the line.

Hi!

import Tkinter as tk

root = tk.Tk()

listbox = tk.Listbox(root)
listbox.pack()

for item in ["one", "two", "three", "four"]:
    listbox.insert(tk.END, item)

listbox.selection_set(first=2)

root.mainloop()

Regards, mawe

Yeah, that works like a charm. Thanks.