Harlin Seritt wrote:
Whenever I set up something similar:

vals = ['1', '2','3']
for v in vals:
   listbox.inset(END, v)

I notice that when this listbox is displayed, there is never a default
value. How can I make sure that one of the indices is selected by
default?


Hi Harlin,

you must use the select_set method of the listbox.

---
from Tkinter import *

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

vals = ['1', '2','3']
for v in vals:
  listbox.insert(END, v)

listbox.select_set(0) # sets the first element

root.mainloop()
---

Some good resources for Tkinter:
http://www.pythonware.com/library/tkinter/introduction/index.htm
http://infohost.nmt.edu/tcc/help/pubs/tkinter/

HTH
Jørgen Cederberg
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to