0

Is there an easy way to return the user selected date value to another python script using this code for a python calendar widget? I've saved the calendar widget in its own file named CalendarWidget.py. I have a main gui with a button that opens the calendar widget.

def callback():
    t=tk.Toplevel()
    t.title("Calendar")
    cal = CalendarWidget.Calendar(t, firstweekday=calendar.SUNDAY)
    cal.pack(expand=1, fill="both")
    cal.selection 

This is working fine. Now I just want to utilize the date. With the instance of cal.selection, I have tried saving the date. However, I am finding the cal.selection line is interpreted before the actual selection is saved. Thus I get a value of None for the calendar widget date.

Thanks for your consideration.

1 Answer 1

0

You could solve this problem by altering your implementation such that when your Toplevel instance is closed, that is when you return cal.selection, or by adding a button whose callback both returns cal.selection and destroys the widget.

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.