简体   繁体   中英

Python, problem with tkinter entry function

When i write this in my python code, it display the next error. What can i do to repair it?

filename = tkinter.StringVar()
entry_function = tkinter.Entry(parent, textvariable=filename, bg="black", font=("Hacker", 15, "normal"),fg= "white", width = 18)
tkinter.Entry.insert(0,'keylogger')
tkinter.Entry.pack(default)

Error

  Messaggio=insert() missing 1 required positional argument: 'string'
  Origine=D:\finale\Homework.py
  Analisi dello stack:
  File "D:\finale\Homework.py", line 138, in <module>
    tkinter.Entry.insert(0,'keylogger')

First define a Entry widget, and then insert a value.

Here is an example:

import tkinter as tk

window = tk.Tk()

ent = tk.Entry(window, width=20)
ent.grid(row=0, column=0)

# insert value
ent.insert(0,'keylogger')

window.mainloop()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM