Home > Net >  Problem with creating a floatlayout in a scrollview in the .py file
Problem with creating a floatlayout in a scrollview in the .py file

Time:12-19

For some reason, while I am trying to add an image to a scrollable floatlayout, the scrollview seems to be really small. How do i fix this?

the following is my python code for the screen.

class RecipeWindow(Screen):
    def on_enter(self):
        scroll = ScrollView(size_hint=(None, None), do_scroll_y=True)
        floatL = FloatLayout(size_hint=(None, None), size=(scroll.width, scroll.height*2))
        floatL.add_widget(Image(source=(f'food_images/{image_index}.png'), pos_hint={'x':0.1, 'y':0.1}, width=1000, height=1000))
        scroll.add_widget(floatL)   
        self.add_widget(scroll)

this is an image of the screen that is returned enter image description here

CodePudding user response:

Just figured out that you should specify the following in the ScrollView:

size=(Window.width, Window.height)

CodePudding user response:

Now the scrollview shouldn't be small:

class RecipeWindow(Screen):

    def on_enter(self):

        scroll = ScrollView(size_hint=(Window.width, Window.height), do_scroll_y=True)
    
        floatL = FloatLayout(size_hint=(None, None), size=(scroll.width, scroll.height*2))
        floatL.add_widget(Image(source=(f'food_images/{image_index}.png'), pos_hint={'x':0.1, 'y':0.1}, width=1000, height=1000))
        scroll.add_widget(floatL)   
        self.add_widget(scroll)
  • Related