Day 3 of the Anvil Advent Calendar
Build a web app every day until Christmas, with nothing but Python!
Grow a Christmas Tree
With this Anvil app, you’ll be able to grow a Christmas tree over Advent, without worrying about pine needles taking over your house. When you water it, it will grow in size - and even magically grow decorations - but if you forget to take care of it for too long, your tree will become sad and withered. Thankfully, a quick watering will get your tree back to health in no time!
This app works offline too, so you can add it to your phone’s home screen to make it extra easy to care for your tree on the go.
You can follow this link to start growing your own tree:
https://grow-a-christmas-tree.anvil.app
How it works
The tree is created in a Canvas component in which the tree is re-drawn as it grows.
To make sure each user has their own tree, we store a small amount of data in local storage. For this app, we want to keep track of the number of times a tree has been watered, and the date and time of its most recent watering. Then depending on those pieces of information, we can calculate exactly how verdant (or withered) your tree ought to be.
If you’d like to see more detail about how this app was built, or play around with it, follow the link below to clone the app:
Give the Gift of Python
Share this post: