Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge rdbende:numberentry into master to add NumberEntry widget #79

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

rdbende
Copy link
Member

@rdbende rdbende commented Mar 25, 2021

PR Details:

  • Widget name: NumberEntry
  • Author: @rdbende

Description

An entry that takes only numbers, calculations, or variables, and calculates the result of the calculation

Checklist

  • Widget in a separate file in the appropriate folder
  • Widget functions properly on both Windows and Linux
  • Widget code includes docstrings with parameter descriptions
  • Included an example file in /examples
  • Widget is covered by unitttests in /tests
  • Widget includes required assets files
  • Reference to widget in AUTHORS.md
  • Entry in sphinx documentation

@codecov
Copy link

codecov bot commented Mar 25, 2021

Codecov Report

Merging #79 (3bad128) into master (2706a43) will decrease coverage by 0.22%.
The diff coverage is 77.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #79      +/-   ##
==========================================
- Coverage   89.63%   89.40%   -0.23%     
==========================================
  Files          43       44       +1     
  Lines        4032     4106      +74     
==========================================
+ Hits         3614     3671      +57     
- Misses        418      435      +17     
Impacted Files Coverage Δ
ttkwidgets/numberentry.py 76.71% <76.71%> (ø)
ttkwidgets/__init__.py 100.00% <100.00%> (ø)

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 2706a43...3bad128. Read the comment docs.

specified in allowed_chars (default is True)
:type variables: bool
"""
self._allowed = allowed_chars
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a serious security threat.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should allow numbers and operator characters only.

self.insert(0, result)
except SyntaxError:
self.delete(0, tk.END)
self.insert(0, "SyntaxError")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad idea. Why would the user care? Simply just do nothing with the expression. Or maybe set the invalid ttk state on the entry

self.insert(0, "ZeroDivisionError")
self.select_range(0, tk.END)

def _check(self, *args):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, this looks cursed. And why didn't I use an actual validator function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant