繁体   English   中英

如何在Kivy中为旋转木马添加按钮和缩放?

[英]How to add buttons and zooming to Carousel in Kivy?

我有Carousel小部件,用于滑动图像。
我需要知道如何在图像下方添加按钮。
而且主要是缩放图像(如Kivy的示例:./ examples / demo / pictures)。
这是我的代码(它从“ image”文件夹中加载多个图像):

#!/usr/bin/kivy

import kivy
kivy.require('1.8.0')

from glob import glob
from os.path import join, dirname
from kivy.app import App
from kivy.uix.carousel import Carousel
from kivy.factory import Factory

class MyClass(App):

    def build(self):    
        # the root is created in pictures.kv
        root = self.root

        # get any files into images directory
        curdir = dirname(__file__)

        carousel = Carousel(direction='right')
        for filename in glob(join(curdir, 'images', '*')):
            image = Factory.AsyncImage(source=filename, allow_stretch=True)
            carousel.add_widget(image)
        return carousel

if __name__ == '__main__':
    MyClass().run()
1. Buttons
Please use a layout to hold the buttons and picture widgets

2. Zooming:
 The Picture class is derived from the Scatter widget. This widget allows rotation and is used in the 47th line in main.py as in:
       picture = Picture(source=filename, rotation=randint(-30,30))
This gives every instance of the Picture class, picture, the ability to be rotated and scaled(zoom in or out) width double-touch events

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM