TkinterEP / ttkwidgets

A collection of widgets for Tkinter's ttk extensions by various authors
GNU General Public License v3.0
137 stars 28 forks source link

Merge validated-entry into master to add ValidatedEntry widget #58

Closed sbordeyne closed 3 years ago

sbordeyne commented 4 years ago

PR Details:

Description

Includes several ttk::Entry widgets that will validate the user input against specific patterns.

Includes :

Checklist

codecov-io commented 4 years ago

Codecov Report

Merging #58 (b192449) into master (5288462) will decrease coverage by 0.26%. The diff coverage is 83.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
- Coverage   89.89%   89.63%   -0.27%     
==========================================
  Files          38       43       +5     
  Lines        3869     4032     +163     
==========================================
+ Hits         3478     3614     +136     
- Misses        391      418      +27     
Impacted Files Coverage Δ
ttkwidgets/validated_entries/validated_entry.py 73.68% <73.68%> (ø)
ttkwidgets/validated_entries/validators.py 77.08% <77.08%> (ø)
ttkwidgets/__init__.py 100.00% <100.00%> (ø)
ttkwidgets/utilities.py 100.00% <100.00%> (ø)
ttkwidgets/validated_entries/__init__.py 100.00% <100.00%> (ø)
ttkwidgets/validated_entries/numbers.py 100.00% <100.00%> (ø)
ttkwidgets/validated_entries/strings.py 100.00% <100.00%> (ø)
... and 2 more

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 5288462...b192449. Read the comment docs.

sbordeyne commented 4 years ago

This is a widget with a lot of potential I think. I have a few questions, but if I am going out of the intended scope of the widget, please reel me back in.

* There is no way that I can see that the programmer can request something of an `is_valid` property or something. Particularly for patterns like e-mails, this seems useful to me, as some input need not be valid when it is entered. For example, entering an e-mail address allows entering any data I like, it seems, requiring the programmer to do another check if it is a form or something like that.

This is a good idea, it's already pretty straightforward to access though, through the self.entry.VALIDATOR._validate(text) method. An is_valid property is very easy to implement, and I will implement it tonight, after work

* Maybe a visual cue could be implemented to indicate the validity of the input? Doing so on the entry itself is complex in `ttk`, especially if custom themes are used, but maybe a checkmark or something similar?

This widget is intended to be as barebones as possible. It's a validating entry, nothing more. Visual cues can be added by subclassing the widgets, but there is so many options for visual cues that it doesn't make sense to implement it in the widget itself.

* Separating the `Validator` and the `ValidatorEntry` feels a bit Java-style, but I understand the reasoning. Perhaps add an option for simply passing a regex to a `ValidatorEntry` to allow quick creation if a `Validator` need only be used once?

It is a bit Java-style but the intention is to have a clear separation between the data and the view, Integrating validation on the widget itself imo would blur the lines and make this whole thing less modular

* From my basic testing, it seems that `Validators` may not be combined or removed. Is this correct?

I intend to make it possible to have multiple validators for one widget (hence this particular architecture) and I will work on that tonight as well.