Python Forum

Full Version: How make a button perform a function after the user inputs numbers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm dabbling in GUI to implement the program I made for an assignment into a GUI, but I have no idea how to solve this.
My plan was for the user to enter numbers into a grid before pressing a button to use those numbers in calculation. I wanted to try printing the number that the user entered to understand how to implement it but he problem is that the program prints the name of the tkinter.Entry instead of printing the number that the user entered.

import tkinter
def skin():
    print(entry_1)
core = tkinter.Tk()
core.title("GUI")
core.geometry("500x500")
label_1 = tkinter.Label(core, text="Year")
label_2 = tkinter.Label(core, text="Day")
entry_1 = tkinter.Entry(core)
entry_2 = tkinter.Entry(core)
label_1.grid(row=0, sticky="E")
label_2.grid(row=1, sticky="E")
entry_1.grid(row=0,column=1)
entry_2.grid(row=1,column=1)
check= tkinter.Button(core, text="Calculate", command=lambda:skin())
check.grid(row=2)
core.mainloop()
That's in every tutorial. Please study a tutorial first so we aren't asked to answer the same beginner questions over and over http://effbot.org/tkinterbook/entry.htm