kivy 滚动imagebutton

在这里插入图片描述

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 root


if __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))
发布了193 篇原创文章 · 获赞 55 · 访问量 4万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览