Reputation:
In tkinter, I test the code when I write every quarter of it. I tested a quarter and python gave this error (the sticky option cannot be found for short and I edited the output a bit (eg: variable, text="sometext", path/to/file.pyw):
Traceback (most recent call last):
File "path/to/file.pyw", line 4, in <module>
variable = tk.Label(text="sometext", sticky="w")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 3148, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 2572, in __init__
self.tk.call(
_tkinter.TclError: unknown option "-sticky"
I'm using a windows laptop if you do need that info.
Upvotes: 0
Views: 903
Reputation: 3987
You are putting sticky in wrong place. You have to put sticky
in .grid(sticky=<>)
. Sticky is not an option of label but it helps to position the label and used in grid method positioning.
sticky − What to do if the cell is larger than widget. By default, with sticky='', widget is centered in its cell. sticky may be the string concatenation of zero or more of N, E, S, W, NE, NW, SE, and SW, compass directions indicating the sides and corners of the cell to which widget sticks.
You can look here for more details and explanation about other options also.
Upvotes: 2