j4321 / tkcalendar

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

Calendar selection position issue for January 2023, dates not correctly greyed out #98

Open photodude opened 1 year ago

photodude commented 1 year ago

Calendar has a selection position issue for January 2023. Wherever you click your selection visually ends up being one row below. Selection works correctly for December 2022.

win 10 Using tkcalendar 1.6.1 with anaconda install python 3.9.15 tk 8.6.12 self.cal=Calendar(root, selectmode='day', firstweekday='sunday', mindate=earliest_date, maxdate=datetime.now())

Images show more dates available even though "maxdate" is set to now (2023-01-04 09:52:08.369092), when you click January 4th visually shows January 11th selected. or the 11th (which should be grey out and shouldn't be available to select) shows the 18th as a white box one row below.

Last image shows 2022 where the 28th was clicked and correctly selected.

offset selection, clicked 11 selection shows 18 offset selection clicked 4 visually shows 11 2022 correct

justindubin commented 1 year ago

Seeing the same behavior in my application

photodude commented 1 year ago
Dasuke commented 1 year ago

I'm having the same issue, I "could fix" this changing the firstweekday='sunday' to firstweekday='monday'.

photodude commented 1 year ago

I'm having the same issue, I "could fix" this changing the firstweekday='sunday' to firstweekday='monday'.

That's in interesting work around, (and may point to what's happening in the code) unfortunately I need to keep firstweekday='sunday' for users.

photodude commented 1 year ago

@j4321 Does the Fix Selection Branch Address the offset date highlighting issue Here and in #99?

If yes, What is needed to move that Branch forward to release?

photodude commented 1 year ago

Here is an Image showing First of the week sunday vs first of the week monday. The calendar has an offset in the weeks displayed. With First of the week sunday December from the previous month is showing at the top of the calendar with first of the week monday Febuary from the next month is showing at the bottom of the calendar.

Something is not correctly changing in the calendar positioning for highlighting when First of the week sunday is selected as it's still following the first of the week monday rules and highlighting the "third" week rather than the "second" week

first of week sunday vs monday

photodude commented 1 year ago

Additional note. If you're not using minimum/maximum date restrictions this issue apparently doesn't show up. So the issue requires both the minimum/maximum date and first of the week Sunday for year 2023 and maximum date as "datetime.now()".

photodude commented 1 year ago

This issue also seems to only affect January 2023. February 2023 seems to work correctly.

jemiele1 commented 1 year ago

I have written about a hack to fix this issue on Issue #99 .

photodude commented 1 year ago

Thanks @jemiele1 I have submitted your proposed code as a PR, I hope that @j4321 will review and adopt the fix. Unfortunately, there is something wrong with the automated code checks for some older Python versions, This code check environment issue is affecting all several existing PRs.