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

Number input supports alignment #1821

Merged
merged 14 commits into from
Mar 22, 2023
Merged

Conversation

kiljoy001
Copy link
Contributor

@kiljoy001 kiljoy001 commented Mar 21, 2023

Implemented set_alignment & set_font for NumberInput

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

This is a good start; a couple of comments inline.

changes/1821.feature.rst Outdated Show resolved Hide resolved
self.number_label.text = f"Double the number is: {number * 2}"
else:
self.number_label.text = "You didn't enter a number"
self.number_label.text = (
"Pick some other numbers that won't add up to zero."
Copy link
Member

Choose a reason for hiding this comment

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

This is a misleading message, because that's not what you're testing with the if.

Copy link
Contributor Author

@kiljoy001 kiljoy001 Mar 22, 2023

Choose a reason for hiding this comment

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

How about "Pick some numbers that add up to more than zero"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the label to show Pick some numbers that add up to more than zero

gtk/src/toga_gtk/widgets/numberinput.py Outdated Show resolved Hide resolved
changes/1817.feature.rst Outdated Show resolved Hide resolved
self.number_label.text = f"Double the number is: {number * 2}"
else:
self.number_label.text = "You didn't enter a number"
self.number_label.text = "Pick some numbers that add up to more than zero"
Copy link
Member

Choose a reason for hiding this comment

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

The old logic exited because number can be blank, which means addition and doubling won't work.

This new example will crash if either value doesn't exist. It would also make sense to report the sum of the two values, rather than double one of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the logic completely to address this:

  • label shows values for each box and sum
  • added basic error handling for null values by displaying a warning to add a number to input box

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Awesome - thanks for the PR!

@freakboy3742 freakboy3742 merged commit dceb0eb into beeware:main Mar 22, 2023
@kiljoy001 kiljoy001 deleted the numberInput branch March 22, 2023 16:39
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.

2 participants