First version: Open Image dialogue
All checks were successful
Build / Build for Android (push) Successful in 33m13s
All checks were successful
Build / Build for Android (push) Successful in 33m13s
This commit is contained in:
parent
5e6563c305
commit
0a7dc3d686
1 changed files with 43 additions and 0 deletions
43
ch.l3d.deutschlandticket/main.py
Normal file
43
ch.l3d.deutschlandticket/main.py
Normal 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()
|
Reference in a new issue