j4321 / tkcalendar

Calendar widget for Tkinter
https://pypi.python.org/pypi/tkcalendar
GNU General Public License v3.0
97 stars 33 forks source link

DateEntry mindate-maxdate disables valid ranges #73

Open StefanCelMareRO opened 3 years ago

StefanCelMareRO commented 3 years ago

Hello, I tried to use mindate and maxdate to limit the range of dates which can be selected. However, the options also disable valid ranges. For example,

        dt_min = date(2012, 1, 10)
        dt_max = date(2014, 12, 30)
        wStart = tkcalendar.DateEntry(menuFrame, date_pattern='d/mm/y',
                                       mindate=dt_min, maxdate=dt_max)

won't let me select a date in January 2014:

iss tkcalendar

Edit: In calendar_.py, on line 957, I changed if y1 == y2 or (y1 - y2 == 1 and m1 == 1 and m2 == 12) or (y2 - y1 == 1 and m2 == 1 and m1 == 12): to if (y1 == y2 and m1 == m2) or (y1 - y2 == 1 and m1 == 1 and m2 == 12) or (y2 - y1 == 1 and m2 == 1 and m1 == 12):

Now it seems to work fine in my case, please check if this is correct.

siriuskht commented 2 years ago

I have had the same problem: Min date: 01.01.2021 (format, dd.mm.yyyy) Max date: 31.12.2022 Days of some month in between the range were greyed out and couldn't be selected.

Details:

With the proposal/fix of " StefanCelMareRO", the problem was solved. @StefanCelMareRO: Many thanks!