'how can I get these functions from a different defined class?

so my code takes 2 date ranges and selects dates that fall in-between them. so the dates are stored in entry frames in Tkinter using this code:

def main():
import tkinter as tk
    e1 = tk.Entry(frame)
    e1.place(relx = 0, rely = 0, relwidth = 0.25,relheight = 0.25)
    e1.pack()

    e2 = tk.Entry(frame)
    e2.place(relx = 0, rely = 0, relwidth = 0.25,relheight = 0.25)
    e2.pack()
b1 = tk.Button(frame, text = "enter", command = button_command)

e1 is the first date and e2 is the second date which the user can enter. and when the enter button is pressed it activated the button command function as seen below:

def button_command():
    date1 = e1.get()
    date2 = e2.get()

however when I print either of the dates it returns a none value. (a value that just says 'none'. does anybody know why. I think its something to do with the classes as I have tried it without defining main and it works fine. however the way I need to implement it in to my project requires it to be under def main() however this has messed up how the code works with the none values. so yeah if anybody could help me out it would be great :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source