Python Forum
tkinter get function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter get function

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)

user_label=tk.Label(text="Username", fg= "white", bg="black", width=25, height=5)
pass_label=tk.Label(text="Password", fg= "white", bg="black", width=25, height=5)

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():
    print (username)

button=tk.Button(text="Click", fg="white", bg="blue", width=25, height=5, command="clicked")

Many Thanks,

On line 25, should you really be passing the string "clicked", or your function?
(Mar-02-2021, 03:51 PM)ndc85430 Wrote: On line 25, should you really be passing the string "clicked", or your function?

MEant to be the function, a silly mistake by me. Everything is now working, thanks!

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter won't run my simple function AthertonH 6 2,677 May-03-2022, 02:33 PM
Last Post: deanhystad
  [Tkinter] tkinter best way to pass parameters to a function Pedroski55 3 3,736 Nov-17-2021, 03:21 AM
Last Post: deanhystad
  Creating a function interrupt button tkinter AnotherSam 2 4,500 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 3,931 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  tkinter -- after() method and return from function -- (python 3) Nick_tkinter 12 5,821 Feb-20-2021, 10:26 PM
Last Post: Nick_tkinter
  Using Tkinter inside function not working Ensaimadeta 3 3,450 Dec-23-2020, 02:57 PM
Last Post: deanhystad
  function in new window (tkinter) Dale22 7 3,833 Nov-24-2020, 11:28 PM
Last Post: Dale22
Star [Tkinter] How to perform math function in different page of Tkinter GUI ravaru 2 4,032 Oct-23-2020, 05:46 PM
Last Post: deanhystad
  Call local variable of previous function from another function with Python3 & tkinter Hannibal 5 3,842 Oct-12-2020, 09:16 PM
Last Post: deanhystad
  tkinter get method is not accepting value when called by function jagasrik 1 2,168 Sep-16-2020, 05:28 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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