the_hunger
the_hunger

Reputation: 13

List of configuration options for TKINTER widgets

Is there a way to list out the configuration options for a Tkinter widget? I found this on the effbot site about Tkinter:

The following dictionary method also works for widgets:

keys() => list

Return a list of all options that can be set for this widget. The name option is not included in this list (it cannot be queried or modified through the dictionary interface anyway, so this doesn’t really matter).

This code:

def callback():
    listbox.delete(0,END)
    for key in b:
        listbox.insert(END, key)
    #listbox.insert(END,str(b))

b = Button(master, text="Delete", command=callback)

Throws this error:

return self.tk.call(self._2, 'cget', '-' + key)
TypeError: Can't convert 'int' object to str implicitly

Any suggestions?

Upvotes: 1

Views: 1555

Answers (1)

falsetru
falsetru

Reputation: 369054

You didn't call keys().

def callback():
    listbox.delete(0,END)
    for key in b.keys():
        listbox.insert(END, key)

Upvotes: 4

Related Questions