Tkinter error when trying to get StringVar
Question:
Im trying to gget used to tkinter on python and when I try to set a StringVar into an entry i just get the following error.
File "e:pythonKeymanagerkeylogger.py", line 53, in Pswlog
username_entry = tk.Entry(root,stringvarialbe=psw2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersmatiAppDataLocalProgramsPythonPython311Libtkinter__init__.py", line 3101, in __init__
Widget.__init__(self, master, 'entry', cnf, kw)
File "C:UsersmatiAppDataLocalProgramsPythonPython311Libtkinter__init__.py", line 2628, in __init__
self.tk.call(
_tkinter.TclError: unknown option "-stringvarialbe"
This is the part of the code where I use tkinter.
root = tk.Tk()
root.geometry("240x100")
root.title('Login')
root.resizable(0, 0)
psw = tk.StringVar(root)
psw2 = tk.StringVar(root)
root.columnconfigure(0, weight=1)
root.columnconfigure(1, weight=3)
username_label = tk.Label(root, text="contraseƱa:")
username_label.grid(column=0, row=0, sticky=tk.W, padx=5, pady=5)
username_entry = tk.Entry(root, textvariable=psw)
username_entry.grid(column=1, row=0, sticky=tk.E, padx=5, pady=5)
username_label = tk.Label(root, text="Repita la contraseƱa:")
username_label.grid(column=0, row=1, sticky=tk.W, padx=5, pady=5)
username_entry = tk.Entry(root,stringvarialbe=psw2)
username_entry.grid(column=1, row=1, sticky=tk.E, padx=5, pady=5)
login_button = tk.Button(root, text="Register")
login_button.grid(column=1, row=3, sticky=tk.E, padx=5, pady=5)
root.mainloop()
Answers:
Typo error.
Change this:
username_entry = tk.Entry(root,stringvarialbe=psw2)
to:
username_entry = tk.Entry(root, textvariable=psw2)
Im trying to gget used to tkinter on python and when I try to set a StringVar into an entry i just get the following error.
File "e:pythonKeymanagerkeylogger.py", line 53, in Pswlog
username_entry = tk.Entry(root,stringvarialbe=psw2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersmatiAppDataLocalProgramsPythonPython311Libtkinter__init__.py", line 3101, in __init__
Widget.__init__(self, master, 'entry', cnf, kw)
File "C:UsersmatiAppDataLocalProgramsPythonPython311Libtkinter__init__.py", line 2628, in __init__
self.tk.call(
_tkinter.TclError: unknown option "-stringvarialbe"
This is the part of the code where I use tkinter.
root = tk.Tk()
root.geometry("240x100")
root.title('Login')
root.resizable(0, 0)
psw = tk.StringVar(root)
psw2 = tk.StringVar(root)
root.columnconfigure(0, weight=1)
root.columnconfigure(1, weight=3)
username_label = tk.Label(root, text="contraseƱa:")
username_label.grid(column=0, row=0, sticky=tk.W, padx=5, pady=5)
username_entry = tk.Entry(root, textvariable=psw)
username_entry.grid(column=1, row=0, sticky=tk.E, padx=5, pady=5)
username_label = tk.Label(root, text="Repita la contraseƱa:")
username_label.grid(column=0, row=1, sticky=tk.W, padx=5, pady=5)
username_entry = tk.Entry(root,stringvarialbe=psw2)
username_entry.grid(column=1, row=1, sticky=tk.E, padx=5, pady=5)
login_button = tk.Button(root, text="Register")
login_button.grid(column=1, row=3, sticky=tk.E, padx=5, pady=5)
root.mainloop()
Typo error.
Change this:
username_entry = tk.Entry(root,stringvarialbe=psw2)
to:
username_entry = tk.Entry(root, textvariable=psw2)