'Trying to make a simple entry widget but keep getting an error
I'm just trying to make a very simple entry widget and grid it on the window but I keep getting an error. Anyway I can fix it?
code:
e = tk.Entry(root, borderwidth=5, width=35)
e.grid(root, row=0,column=0, columnspan=3, padx=10, pady=10)
Error:
Traceback (most recent call last):
File "C:\Users\mosta\PycharmProjects\pythonProject\main.py", line 298, in <module>
e.grid(root, row=0, column=0, columnspan=3, padx=10, pady=10)
File "C:\Users\mosta\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 2522, in grid_configure
self.tk.call(
_tkinter.TclError: bad option "-bd": must be -column, -columnspan, -in, -ipadx, -ipady, -padx, -pady, -row, -rowspan, or -sticky
Solution 1:[1]
You need to remove the argument root from the grid command.
e.grid(row=0,column=0, columnspan=3, padx=10, pady=10)
Solution 2:[2]
By using the .place() method instead of the .grid() method, I have successfully gotten the Entry widget to work.
from tkinter import *
root = Tk()
e = Entry(root, borderwidth=5)
e.place(x=10, y=10, height=25, width=180)
I hope that this helps :-)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bryan Oakley |
| Solution 2 | Kiki-Jiki |
