Reputation: 9542
I found this Python calendar widget though this post. I am trying to print out the date that user selected on the calendar. What i tried is something like this
mycalendar=Calendar()
print mycalendar.selection()
I know this small piece of code alone doesn't make things clear. "Calendar" is a class and selection(self) is a function inside Calendar class with return value. For clear understanding please see the link i provided above as the code is too long to post here.
My problem is once i run the script, instead of giving me the return number from function, it give me this error message "TypeError: 'NoneType' object is not callable". Is there any way to get the user selected date on the calendar to printed out?
Upvotes: 0
Views: 2567
Reputation: 174758
From the class you posted, the _pressed
function is called the after user clicks the mouse inside the calendar window.
To print the date, add print self.selection
after the following code block:
# update and then show selection
text = '%02d' % text
self._selection = (text, item, column)
self._show_selection(text, bbox)
print self.selection # print the date selected to the console
Upvotes: 1