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?
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
Reply
#5
Could someone help me out with this problem? Thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter - How can I extend a label widget? TurboC 2 299 Oct-13-2020, 12:15 PM
Last Post: zazas321
  How to set the calendar widget to current date scratchmyhead 4 601 May-11-2020, 08:27 PM
Last Post: scratchmyhead
  [Tkinter] Tkinter custom widget styling and creating custom theme karolp 6 1,179 May-06-2020, 06:11 PM
Last Post: karolp
  [PyGUI] Python 3.8.1 Tkinter Widget stete change sasiap 4 581 Feb-14-2020, 10:38 AM
Last Post: sasiap
  [Tkinter] Retrieving a value from a calendar with a single click LagratteCchouette 4 1,995 Jan-26-2020, 04:36 PM
Last Post: LagratteCchouette
  Restoring Tkinter widget background to original color pythonprogrammer 1 817 Dec-16-2019, 04:59 AM
Last Post: woooee
  GUI Tkinter Widget Positions punksnotdead 3 956 Jun-12-2019, 06:06 PM
Last Post: Yoriz
  how to insert image into Text widget Tkinter atlass218 5 4,665 Apr-17-2019, 05:28 AM
Last Post: atlass218
  [Tkinter] Problem with tkinter search widget poopcupine 1 1,215 Mar-25-2019, 08:24 AM
Last Post: Larz60+
  TKinter Slider widget Jemeronimo 1 1,965 Jan-29-2019, 05:32 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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