K
Kevin Walzer
I'm trying to set the active item in a Tkinter listbox to my
application's currently-defined default font.
Here's how I get the fonts loaded into the listbox:
self.fonts=list(tkFont.families())
self.fonts.sort()
for item in self.fonts:
self.fontlist.insert(END, item) #self.fontlist is the
ListBox instance
So far, so good. But I don't know how to set the active selection in the
listbox to the default font. All the methods for getting or setting a
selection in the listbox are based on index, not a string. And using
standard list search methods like this:
if "Courier" in self.fontlist:
print "list contains", value
else:
print value, "not found"
returns an error:
TypeError: cannot concatenate 'str' and 'int' objects
So I'm stuck. Can someone point me in the right direction?
application's currently-defined default font.
Here's how I get the fonts loaded into the listbox:
self.fonts=list(tkFont.families())
self.fonts.sort()
for item in self.fonts:
self.fontlist.insert(END, item) #self.fontlist is the
ListBox instance
So far, so good. But I don't know how to set the active selection in the
listbox to the default font. All the methods for getting or setting a
selection in the listbox are based on index, not a string. And using
standard list search methods like this:
if "Courier" in self.fontlist:
print "list contains", value
else:
print value, "not found"
returns an error:
TypeError: cannot concatenate 'str' and 'int' objects
So I'm stuck. Can someone point me in the right direction?