j4321 / tkcalendar

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

Fix behaviour in readonly state #12

Closed drepekh closed 6 years ago

codecov[bot] commented 6 years ago

Codecov Report

Merging #12 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #12   +/-   ##
=======================================
  Coverage   91.89%   91.89%           
=======================================
  Files           2        2           
  Lines         827      827           
=======================================
  Hits          760      760           
  Misses         67       67
Impacted Files Coverage Δ
tkcalendar.py 91.17% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 059331e...d351971. Read the comment docs.

j4321 commented 6 years ago

Could you please provide a description of what you have done, especially what was wrong in the behavior in readonly mode?

drepekh commented 6 years ago

There is a couple of places in the code, where you try to insert text in the entry, but only one of them (function _select) is wrapped with check for 'readonly' state (set to normal, insert, than set back to readonly). This leads to the following problems: 1) Entry will be empty if you try to init it with state='readonly' (entry's init calls insert()), and any following attempt to open drop down calendar will cause an error, because _validate_date() should have inserted text in the entry, but it did not, and drop_down() calls strptime on an empty string. 2) set_date doesn't work because, again, it calls insert without checking readonly state. And so on. I just wrote function _set_text based on your code from _select, and replaced all insert calls with it.