这个ttk日历类根据tkinter制作日历.如何让它返回所选日期的值?下面是我试过的,它返回'NoneType对象不可调用':
def test():
import sys
root = Tkinter.Tk()
root.title('Ttk Calendar')
ttkcal = Calendar(firstweekday=calendar.SUNDAY)
ttkcal.pack(expand=1, fill='both')
x = ttkcal.selection() #this and the following line are what i inserted
print 'x is: ', x #or perhaps return x
if 'win' not in sys.platform:
style = ttk.Style()
style.theme_use('clam')
root.mainloop()
if __name__ == '__main__':
test()
Run Code Online (Sandbox Code Playgroud)