First version: Open Image dialogue
All checks were successful
Build / Build for Android (push) Successful in 33m13s

This commit is contained in:
L3D 2023-05-12 17:53:33 +02:00
parent 5e6563c305
commit 0a7dc3d686
Signed by: l3d
GPG key ID: CD08445BFF4313D1

View file

@ -0,0 +1,43 @@
#/usr/bin/env python3
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.button import Button
from kivy.uix.filechooser import FileChooserIconView
class ImageChooser(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.orientation = 'vertical'
self.file_chooser = FileChooserIconView()
self.add_widget(self.file_chooser)
self.open_button = Button(text='Open Image')
self.open_button.bind(on_press=self.open_image)
self.add_widget(self.open_button)
def open_image(self, instance):
if self.file_chooser.selection:
# Show Image
self.image = Image()
self.add_widget(self.image)
# Load Image
image_path = self.file_chooser.selection[0]
self.image.source = image_path
# Hide other Elements
self.remove_widget(self.file_chooser)
self.remove_widget(self.open_button)
class DeutschlandTicket(App):
def build(self):
return ImageChooser()
if __name__ == '__main__':
app = DeutschlandTicket()
app.run()