1

In MDTextField, there is a restriction on entering only numbers, this is input_filter: "float", "int". But you can enter negative numbers

MDTextField:
    id: z1_m
    text:""
    hint_text: "z1"
    helper_text: "Число зубьев шестерни"                        
    helper_text_mode: "on_focus"
    input_filter: "float"                                               
    on_text_validate: app.prochnjst()

Expected that when the user enters a minus sign, nothing happens

Luuk
  • 12,245
  • 5
  • 22
  • 33
Edem
  • 13
  • 2
  • 1
    Does this answer your question? [Reject Negative Numbers as exceptions in Python](https://stackoverflow.com/questions/34244588/reject-negative-numbers-as-exceptions-in-python) – Luuk Jan 21 '23 at 12:43

1 Answers1

0

You can use try/ except:

try: 
  x = int(input())
  assert x > 0 
except AssertionError :
  print("Only positives are allowed")
Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44