Home > front end >  Trying to make a simple entry widget but keep getting an error
Trying to make a simple entry widget but keep getting an error

Time:02-18

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

CodePudding user response:

You need to remove the argument root from the grid command.

e.grid(row=0,column=0, columnspan=3, padx=10, pady=10)

CodePudding user response:

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 :-)

  • Related