Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Displays and switches between images using buttons in Kivy.
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.button import Button
class ImageViewer(App):
def build(self):
self.images = ['1.png','2.png','3.png']
self.index = 0
self.layout = BoxLayout(orientation='vertical')
self.img = Image(source=self.images[self.index])
btn_next = Button(text='Next', on_press=lambda x: self.next_img())
self.layout.add_widget(self.img)
self.layout.add_widget(btn_next)
return self.layout
def next_img(self):
self.index = (self.index + 1) % len(self.images)
self.img.source = self.images[self.index]
if __name__ == '__main__':
ImageViewer().run()Kivy is an open-source Python framework for building cross-platform multitouch applications on Android, iOS, Windows, macOS, Linux, and Raspberry Pi. It provides a UI toolkit, gesture support, animations, layouts, and a declarative KV language for rapid app development.
Origin & Creator
Kivy was created by Mathieu Virbel and the Kivy Organization, evolving from the PyMT project and released publicly in 2011 as a modern Python GUI + mobile app framework.
Industrial Note
Kivy is especially loved in education, research environments, rapid prototyping, Raspberry Pi projects, and Python-first development teams requiring cross-platform touch UIs.