First post…be gentle. I have searched the forums for an answer but haven’t found anything yet.
I’ve put together an app for myself to monitor temperature and humidity in my greenhouse (everyone’s gotta have a hobby, right?). Eventually, this’ll be logged automatically with a Rasp Pi and Uplink. But for now, I’ve put together a simple app fo rme to enter values manually and save them to a data table. Easy enough.
To speed things up, rather than have to pick time and date on the DatePicker every time I want to enter a reading, I’ve put a “Now” button next to the DatePicker which uses the following to set the date and time to now:
The button works, filling in the time and date. However, the time behaviour is not as expected. I’ve just tried it (at 11:11) and the time entered to the DatePicker was 11:04. And it always seems to choose hh:04, no matter what time of day I try it. Previously, I was entering the time and date now as default text and the behaviour was the same.
Any ideas on why this is behaving like this?
Also, as a slight aside, is there a way to clear the currently set date and re-display placeholder text in a DatePicker? Apologies for the 2 questions in one…
That is a much more elegant way of getting current time and date, and formatting the DatePicker. I hadn’t thought of that. And it works nicely.
What is interesting (to me at least) is that the method you show above uses the same Python library (datetime) to get the current time and date, but what is displayed is the actual current time. Whereas my implementation always had hh:04.
should always return the minute?
Maybe I’ll try it next month and see if I start getting hh:05 !
I have a prototype. But at the moment anyone can enter a reading. I’d like to lock it down a little before letting everyone put in all sorts of data. My tomatoes won’t grow in temperatures of 300 degrees! I’m going to add a plot to show historical data, and maybe add a login for me to record real data (with a usable non-logged-in version).
I’m using this as a good excuse to learn more Python and Anvil! And to make a digital twin of my greenhouse…
you can share the code without sharing the live app.
This way I can clone it and dig around and see what the weird 04 error was.
Go to the gear icon and hit share. Then find the clone link to share the source code and data tables.
of course no need if you’d prefer not to share it.