Python Forum
tkinter get function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter get function
#1
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
Reply


Messages In This Thread
tkinter get function - by finndude - Mar-02-2021, 03:41 PM
RE: tkinter get function - by ndc85430 - Mar-02-2021, 03:51 PM
RE: tkinter get function - by finndude - Mar-02-2021, 03:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter -- after() method and return from function -- (python 3) Nick_tkinter 12 1,261 Feb-20-2021, 10:26 PM
Last Post: Nick_tkinter
  Using Tkinter inside function not working Ensaimadeta 3 892 Dec-23-2020, 02:57 PM
Last Post: deanhystad
  function in new window (tkinter) Dale22 7 1,032 Nov-24-2020, 11:28 PM
Last Post: Dale22
Star [Tkinter] How to perform math function in different page of Tkinter GUI ravaru 2 1,222 Oct-23-2020, 05:46 PM
Last Post: deanhystad
  Call local variable of previous function from another function with Python3 & tkinter Hannibal 5 1,251 Oct-12-2020, 09:16 PM
Last Post: deanhystad
  tkinter get method is not accepting value when called by function jagasrik 1 772 Sep-16-2020, 05:28 AM
Last Post: Yoriz
  [Tkinter] Use function from other class (Tkinter) zarize 8 1,468 Aug-17-2020, 09:47 AM
Last Post: zarize
  [Tkinter] updating tkinter chart from within function mikisDW 1 717 Jul-02-2020, 03:33 AM
Last Post: deanhystad
  Passing arguments into function, tkinter nanok66 3 1,638 Apr-18-2020, 11:53 PM
Last Post: nanok66
  Tkinter:Unable to bind and unbind function with a button shallanq 2 2,156 Mar-28-2020, 02:05 AM
Last Post: joe_momma

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020