title: How do I store the date from a tkinter calendar in a variable?
body: <p>I have the following work in progress code where I am trying to have a user input a date from a calendar, but I am very new to using tkinter,tkcalendar so I am not sure how to get the input to store as a variable that I can pass along to use elsewhere:</p>
  <pre class="lang-py prettyprint-override"><code>def addGameTimeInfo():
      #week_number = input('Enter the week number of this game:')
      #game_date = input('Enter the date for this game(YYYY/MM/DD):')
      #season_number = input('Enter Season Number for this game:')
      def calendar_view():
          def print_sel():
              print(cal.selection_get())
  
          top = Toplevel(root)
  
          cal = Calendar(top,
                         font=&quot;Arial 14&quot;, selectmode='day',
                         cursor=&quot;hand1&quot;)
          cal.pack(fill=&quot;both&quot;, expand=True)
          ttk.Button(top, text=&quot;ok&quot;, command=print_sel).pack()
      def dateentry_view():
          def print_sel(e):
              print(cal.get_date())
          top = Toplevel(root)
          
          ttk.Label(top, text = 'Choose date').pack(padx=10,pady=10)
          cal = DateEntry(top, width=12, background = 'darkblue',
                         foreground ='white',borderwidth=2)
          cal.pack(padx=10,pady=10)
          cal.bind('&lt;&lt;DateEntrySelected&gt;&gt;',print_sel)
      
      root = Tk()
      s = ttk.Style(root)
      s.theme_use('clam')
      
      ttk.Button(root, text = 'Calendar',command=calendar_view).pack(padx=10,pady=10)
      ttk.Button(root,text='DateEntry',command=dateentry_view).pack(padx=10,pady=10)
      root.mainloop()
  </code></pre>
  <p>I saw this being discussed in another post but I can not comment as I am a new user, otherwise I would have posted there. Thank you!</p>