I've spent the better part of a hour just trying to find the solution to this error: TypeError: insert() missing 1 required positional argument: 'string' ... Someone please help D: Here is a small piece of code that I wrote. And yea I am very new to python and tkinter.. Probably just a noob mistake..
from tkinter import *
root = Tk()
root.geometry("300x300")
message = Entry(root, width=10).grid(row=1, column=1)
message = Entry.insert(message, "default")
root.mainloop()
And here is the error that i keep getting:
Traceback (most recent call last):
File "E:\Hidden\DoS\_console.py", line 6, in <module>
message = Entry.insert(message, "default")
TypeError: insert() missing 1 required positional argument: 'string'
This is the definition of insert
method:
insert(index, string)
Inserts text at the given index. Useinsert(INSERT, text)
to insert text at the cursor,insert(END, text)
to append text to the widget.
I think you need to use it like this:
message = Entry(root, width=10).grid(row=1, column=1)
message.insert(INSERT, "default")
I used INSERT
to insert the text at cursor position.
If you need to add it in the start:
message.insert(0, "default")
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments