python日期选择框_如何在tkinter中创建日期选择器?

如果任何人仍然需要这个——这里有一个简单的代码来使用tkcalendar包创建日历和DateEntry小部件。pip install tkcalendar [for installing the package]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='dark

你可能感兴趣的:(python日期选择框)