How do I create a date picker in tkinter?

前端 未结 7 1403
借酒劲吻你
借酒劲吻你 2020-11-28 09:45

Is there any standard way tkinter apps allow the user to choose a date?

7条回答
  •  清酒与你
    2020-11-28 10:21

    No, but you can get it from the user as a datetime element from a formatted string..

    Example:

    import datetime
    
    userdatestring = '2013-05-10'
    thedate = datetime.datetime.strptime(userdatestring, '%Y-%m-%d') 
    

    Check out http://docs.python.org/2/library/datetime.html#strftime-strptime-behavior. It's handy, although not the most user friendly way of getting a date.

提交回复
热议问题