Hello, I am trying to get a time inputted by the user and save it as a string so it can be inputted into my code. In the properties of the TextBox I made the input a number and in the code I added a .text to the end of the self.textbox code, as per the tutorial linked to the website. I tired doing it in military time but it did not work and I tried with normal time and it did not work. My suspicion is that when inputting military time like 0900, the first zero is disregarded, and as for normal time, it does not know how to store AM/PM as a number. Does anyone know if it is being saved as a string/int/other or another method to approach this? I also tried using the calendar method but I am not sure of the format of the output.
Welcome to the Anvil Forum!
You’ve instructed your TextBox to treat the input as a number, so it will only accept (and return) base-10 numbers. If you want it to accept something else, pick the appropriate type
of value.
Since you want leading zeroes, and non-number text (the AM/PM) – that is, you want to be able to enter text “as is” – the type
will need to be “text”, not “number”.
For reference, you can start here: TextBox .
The value from a Calendar widget is a Python date
or datetime
object. See datetime — Basic date and time types — Python 3.7.17 documentation for ways to convert this value to and from text, in your desired format.
1 Like
thank you so much for your help