我有用于滑动图像的Carousel小部件
我需要知道如何在图像下添加按钮
主要是缩放图像(如Kivy的例子:./ example / demo / picture)。
这是我的代码(它从" 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()
答案 0 :(得分:0)
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