好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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 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))

               

查看更多关于kivy 滚动imagebutton的详细内容...

  阅读:35次

上一篇: kivy文件选择

下一篇:kivy画条线