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

toga.NumberInput() on Windows does not accept decimal point in languages that use decimal comma #2773

Open
Pogzy opened this issue Aug 17, 2024 · 1 comment
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.

Comments

@Pogzy
Copy link

Pogzy commented Aug 17, 2024

Describe the bug

When trying to set a toga.NumberInput() with a decimal step, such as vmag = toga.NumberInput(max=12, min=7, step=0.1)
there is an error at run time:

  File "C:\Users\Fabien\Documents\beeware-tutorial\astrofilter\src\astrofilter\app.py", line 24, in startup
    self.vmag = toga.NumberInput(max=12, min=7, step=0.1)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fabien\Documents\beeware-tutorial\beeware-venv\Lib\site-packages\toga\widgets\numberinput.py", line 153, in __init__
    self.step = step
    ^^^^^^^^^
  File "C:\Users\Fabien\Documents\beeware-tutorial\beeware-venv\Lib\site-packages\toga\widgets\numberinput.py", line 189, in step
    self._impl.set_step(self._step)
  File "C:\Users\Fabien\Documents\beeware-tutorial\beeware-venv\Lib\site-packages\toga_winforms\widgets\numberinput.py", line 41, in set_step
    self.native.Increment = native_decimal(step)
                            ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fabien\Documents\beeware-tutorial\beeware-venv\Lib\site-packages\toga_winforms\widgets\numberinput.py", line 18, in native_decimal
    return Convert.ToDecimal.__overloads__[String](str(value))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
System.FormatException: Le format de la chaîne d'entrée est incorrect.
   à System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   à System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
   à System.Convert.ToDecimal(String value)

Steps to reproduce

  1. write any minimal app with a decimal step, not integer
  2. run it under windows (not tested on other platform
  3. see the error

Expected behavior

It should work with decimam number, such as described in the online documentation.

It does not work even if the step is a string

Screenshots

No response

Environment

  • Operating System: Windows 10
  • Python version: 3.11
  • Software versions:
    • Briefcase: 0.3.19
    • Toga: 0.4.5
    • ...

Logs


Additional context

No response

@Pogzy Pogzy added the bug A crash or error in behavior. label Aug 17, 2024
@mhsmith mhsmith added the windows The issue relates to Microsoft Windows support. label Aug 19, 2024
@mhsmith mhsmith changed the title toga.NumberInput() dose not accept decimal number on python 3.11 toga.NumberInput() on Windows does not accept decimal point in languages that use decimal comma Aug 19, 2024
@mhsmith
Copy link
Member

mhsmith commented Aug 19, 2024

Thanks for the report. This is probably because your system language is set to French, so Windows is expecting a decimal comma, but Toga is passing a decimal point.

I wouldn't be surprised if other platforms have a similar problem. For example, here is a related issue I hit on Android in a different project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.
Projects
None yet
Development

No branches or pull requests

2 participants