Kivy was designed from the ground up with fingers, rather than pointing devices, in mind as a primary method of input. You haven’t had much direct interaction with input devices in this book; instead, we’ve focused on touch events that are built into widgets supplied with Kivy. Buttons can be pressed, inputs can have text entered into them, and
ListViews can be scrolled with a gesture.
In this chapter, you’ll delve a bit deeper into Kivy’s event system and add a few basic gestures to the app. The gestures will be swipe left and swipe right on the current weather and forecast widgets, which will switch to the other widget. The swipe down gesture will be used to refresh the weather. This is a fairly standard interaction feature in mobile computing.
First, take some time to implement the forecast widget, so you have something to use gestures to switch between. As in Chapter 6, this should be old hat for you, so I’m just going to summarize the changes. Then I can focus on giving you new and interesting content! I recommend you try to implement these steps before referring to the example code.
ForecastLabelclass to weather.kv to render individual forecast data. Put an icon, conditions, and temperature min and max on it. See Example 7-1.
BoxLayoutto main.py and weather.kv ...