FileView extends the kivy ScrollView. In the app I can see three out of the four image, but I am not able to scroll to the fourth image. Therefore the widget is larger than my app window and I thought that I should be able to scroll. But, I cannot scroll.
This is my python code:
import os
import sys
#self-programmed modules
import modules.pmail as pmail
import modules.log as log
#kivy modules
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
from kivy.core.window import Window
from kivy.properties import StringProperty
logging = True
log.start(logging)
class FileViewPhoto(Button):
source = StringProperty()
class FileView(ScrollView):
pass
class Photo(BoxLayout):
pass
class PhotoCamera(BoxLayout):
'''
Start screen, from here a photo or gif can be taken or previously taken images be viewed
'''
def take_pic(self):
log.printlog('take_pic', logging)
App.get_running_app().root.show_Photo()
def take_gif(self):
log.printlog('take_gif', logging)
App.get_running_app().root.show_Photo()
class PhotoRoot(BoxLayout):
'''
Root widget
-all methods which change the content of the screen are called from here.
'''
def show_Photo(self):
self.clear_widgets()
self.add_widget(Photo())
def show_Photos_in_folder(self):
self.clear_widgets()
self.add_widget(FileView())
class PhotoboothApp(App):
def build(self):
self.icon = 'Icons/photo.png'
if __name__ == '__main__':
PhotoboothApp().run()
This is my kv file:
PhotoRoot:
PhotoCamera:
<PhotoCamera>:
Button:
text: 'Camera-Gif'
on_press: root.take_gif()
BoxLayout:
orientation:'vertical'
pos: self.parent.pos
size: self.parent.size
Image:
source: 'Icons/photo.png'
Image:
source: 'Icons/photo.png'
Image:
source: 'Icons/photo.png'
Button:
on_press: root.take_pic()
Image:
width: self.parent.width
source: 'Icons/photo.png'
center: self.parent.center
Button:
text: 'Photos'
on_press: app.root.show_Photos_in_folder()
<Photo>:
Label:
text: 'Photo'
Image:
source: 'Images/Astronaut1.jpg'
<FileViewPhoto>:
source: ''
size_hint_y: None
height: '300sp'
Image:
source: root.source
center: root.center
size: root.size
<FileView>:
GridLayout:
cols: 1
size_hint_y: None
row_default_height: '200dp'
row_force_default: True
minimum_height: self.minimum_height
FileViewPhoto:
source: 'Images/Astronaut1.jpg'
FileViewPhoto
source: 'Images/Astronaut1.jpg'
FileViewPhoto
source: 'Images/Astronaut1.jpg'
FileViewPhoto:
source: 'Images/Astronaut1.jpg'
The method show_Photos_in_folder() of my PhotoRoot is called to display the supposedly scrollable GridLayout of photos.