Python Forum
Tkinter calendar widget
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter calendar widget
#1
Hello. I'm new to Python and just started using Tkinter. I'm trying to use a calendar widget and I found this code from google search. The code works fine on my work computer but for some reason, it doesn't work on my home computer. Below is the code and I have attached a pic of the output screen. Any help would be appreciated.

try:
    import tkinter as tk
    from tkinter import ttk
except ImportError:
    import Tkinter as tk
    import ttk

from tkcalendar import Calendar, DateEntry

def example1():
    def print_sel():
        print(cal.selection_get())

    top = tk.Toplevel(root)

    cal = Calendar(top,
                   font="Arial 14", selectmode='day',
                   cursor="hand1", year=2018, month=2, day=5)
    cal.pack(fill="both", expand=True)
    ttk.Button(top, text="ok", command=print_sel).pack()

def example2():
    top = tk.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)

root = tk.Tk()
s = ttk.Style(root)
s.theme_use('clam')

ttk.Button(root, text='Calendar', command=example1).pack(padx=10, pady=10)
ttk.Button(root, text='DateEntry', command=example2).pack(padx=10, pady=10)

root.mainloop()

Attached Files

Thumbnail(s)
       
Reply
#2
Did you do python3.8 -m pip install tkcalendar or which ever python version you're using?
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
I'm using Python 3.8 but I think that my work computer is Python 3.7
Reply
#4
python3.8 is what I use
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#5
Could someone help me out with this problem? Thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TKinter Widget Attribute and Method Quick Reference zunebuggy 3 786 Oct-15-2023, 05:49 PM
Last Post: zunebuggy
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,664 Jun-26-2022, 06:26 PM
Last Post: menator01
  Tkinter Exit Code based on Entry Widget Nu2Python 6 2,871 Oct-21-2021, 03:01 PM
Last Post: Nu2Python
  tkinter text widget word wrap position chrisdb 6 7,444 Mar-18-2021, 03:55 PM
Last Post: chrisdb
  Tkinter - How can I extend a label widget? TurboC 2 2,731 Oct-13-2020, 12:15 PM
Last Post: zazas321
  How to set the calendar widget to current date scratchmyhead 4 7,028 May-11-2020, 08:27 PM
Last Post: scratchmyhead
  [Tkinter] Tkinter custom widget styling and creating custom theme karolp 6 4,744 May-06-2020, 06:11 PM
Last Post: karolp
  [PyGUI] Python 3.8.1 Tkinter Widget stete change sasiap 4 2,466 Feb-14-2020, 10:38 AM
Last Post: sasiap
  [Tkinter] Retrieving a value from a calendar with a single click LagratteCchouette 4 9,534 Jan-26-2020, 04:36 PM
Last Post: LagratteCchouette
  Restoring Tkinter widget background to original color pythonprogrammer 1 2,909 Dec-16-2019, 04:59 AM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020