tkinter get function - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: tkinter get function (/thread-32742.html) |
tkinter get function - finndude - Mar-02-2021 Hi, I have the below code. What i want it to do is that when the button is clicked it outputs what is in the two entry boxes. However when I press the button nothing happens, what am I doing wrong? import tkinter as tk window = tk.Tk() label = tk.Label(text="Type Below", fg="white", bg="black", width=10, height=5) label.grid(row=0) user_label=tk.Label(text="Username", fg= "white", bg="black", width=25, height=5) user_label.grid(row=1) pass_label=tk.Label(text="Password", fg= "white", bg="black", width=25, height=5) pass_label.grid(row=2) username_1=tk.Entry(fg="blue", bg="green", width=50) username_1.grid(row=1, column=1) password_1=tk.Entry(fg="blue", bg="green", width=50) password_1.grid(row=2, column=1) def clicked(): username=username_1.get() password=password_1.get() print (username) print(password) button=tk.Button(text="Click", fg="white", bg="blue", width=25, height=5, command="clicked") button.grid(row=3) window.mainloop()Many Thanks, finndude RE: tkinter get function - ndc85430 - Mar-02-2021 On line 25, should you really be passing the string "clicked" , or your function?
RE: tkinter get function - finndude - Mar-02-2021 (Mar-02-2021, 03:51 PM)ndc85430 Wrote: On line 25, should you really be passing the string MEant to be the function, a silly mistake by me. Everything is now working, thanks! |