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()

 
1
  • If you really want to pass arguments to your function, check the answers here. 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. Commented Dec 1, 2021 at 11:32

1 Answer 1

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.