0

What I want is, that take input from the User through Tkinter. I pass the inputs as an argument to my function and then the function performs itself.

Here is my Code-

import tkinter as tk
from tkinter import *
root=tk.Tk()
root.geometry("644x344")
def getvals(email,date_to,date_from):
    """
    function executes itself 
    """    
Label(root,text="Automatic Email Saver",font="comicansms 13 bold",pady=15).grid(row=0,column=3)
Email = Label(root, text="Email")
date_start = Label(root, text="Starting Date And Time")
date_end = Label(root, text="Ending Date and Time")
Email.grid(row=1, column=2)
date_start.grid(row=2, column=2)
date_end.grid(row=3, column=2)
Emailvalue = StringVar()
date_startvalue = StringVar()
date_endvalue = StringVar()
Emailentry = Entry(root, textvariable=Emailvalue)
date_toentry = Entry(root, textvariable=date_startvalue)
date_endentry = Entry(root, textvariable=date_endvalue)
Emailentry.grid(row=1, column=3)
date_toentry.grid(row=2, column=3)
date_endentry.grid(row=3, column=3)
Button(text="Submit", command=getvals).grid(row=5, column=3)
root.mainloop()

 
Rishab S
  • 37
  • 6
  • If you really want to pass arguments to your function, check the answers [here](https://stackoverflow.com/questions/6920302/how-to-pass-arguments-to-a-button-command-in-tkinter). But you also have the option of defining `getvals` with no arguments and within it your vars objects will still be found from the global scope. Or more cleanly, put your window in a class where your vars are stored as attributes and getvals is a method. – Reti43 Dec 01 '21 at 11:32

1 Answers1

1

You need not use any arguments for your function.

Just simply .get() the values.

email = Emailentry.get()
date_to = date_toentry.get()
date_from = date_endentry.get()