How do I get possible values for tkinter’s configure options?
You’ll want to go to the Tk docs for the widget you’re using, and look at the available options.
I see, widget options equal to .congigure() method options.
Well, now I have experimented a little bit and I can see that widget options do not equal configuration options. For example, pady
and padx
options of a widget Label, do not work when configuring Label via .config()
method. As could be seen in Tk docs, the right option is padding
. And that is exactly what I am asking about. If there is a list of configuration options for each label within tkinter.
You are unlucky that you choose an option that differs between tk and ttk. Check out the following:
>>> import tkinter as tk
>>> from tkinter import ttk
>>> l1 = tk.Label(text="This is a tk label")
>>> l1.grid(row=0, column=0)
>>>
>>> l2 = ttk.Label(text="This is a ttk label")
>>> l2.grid(row=1, column=0)
>>> l1.configure(padx=5, pady=10)
>>> l2.configure(padding=(5,10))
>>> l2.configure(padx=5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.11/tkinter/__init__.py", line 1702, in configure
return self._configure('configure', cnf, kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/tkinter/__init__.py", line 1692, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-padx"
So this is not caused by a difference between options in the label widget, but by using a different widget .
The documentation @TeamSpen210 pointed at, is definitely the place to go to find configuration options:
For the tk Label:
-padx, padX, Pad
-pady, padY, Pad
For the ttk.Label: