您的位置:首页 > 其它

kivy 滚动imagebutton

2021-04-22 23:13 120 查看

class ImageButton(ButtonBehavior, FloatLayout, Image):
    def on_press(self):
        # 这里面可以定义一些处理函数 弹出显示大图还是动态的eee
        print('pressed',self)

class ScrollView_layout_image():
    def myself_scrollview(self,image_list):
        layout = GridLayout(cols=1, spacing=10, size_hint_y=None)
        # Make sure the height is such that there is something to scroll.
        layout.bind(minimum_height=layout.setter('height'))
        for one_image in image_list:
            layout1 = GridLayout(cols=1, spacing=10, size_hint_y=None)

            layout1.add_widget(ImageButton(texture=one_image))
            layout.add_widget(layout1)
        root = ScrollView(do_scroll_x=False,do_scroll_y=True,size_hint=(1, None), size=(Window.width, Window.height))
        root.add_widget(layout)
        return rootif __name__ == '__main__':
    image_list=[]
    for i in range(100):
        image_list.append(Image(source='./face_boder.png').texture)
    runTouchApp(ScrollView_layout_image().myself_scrollview(image_list))

               

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: