Arya
Arya

Reputation: 31

what are the parameters of configure method of tkinter/tk()

Code:

root = Tk()
root.configure(background="red")

Which parameters (args) are present in the .configure method.

Is it just background and if not how do I view them?

Upvotes: 3

Views: 19842

Answers (2)

AFK on core
AFK on core

Reputation: 1

To add to the answer above you may want to print(tkinter.Tk().configure().keys()), it took me couple minutes to figure out why it wasn't doing anything

Upvotes: 0

Aran-Fey
Aran-Fey

Reputation: 43136

The parameters for the configure method are different for each widget.

Tkinter's widgets have a concept of options like color and size and so on. Some of these options exist for every widget, but others don't. For example, the Entry class has a validatecommand option that most other widgets don't have.

The configure method lets you change the options of a widget, and the available parameters depend on the widget you're configuring. Entry().configure(validatecommand=bool) would be valid, but Label().configure(validatecommand=bool) wouldn't.

To find a complete list of valid parameters/options you can either look at the documentation of the widget, or call the configure method without parameters, which will list all the available options:

>>> root.configure().keys()
dict_keys(['bd', 'borderwidth', 'class', 'menu', 'relief', 'screen', 'use', 'background', 'bg', 'colormap', 'container', 'cursor', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'padx', 'pady', 'takefocus', 'visual', 'width'])

Upvotes: 6

Related Questions