如何限制显示的猕猴桃微调器项目的数量 [英] How to limit the number of displayed kivy spinner items

查看:73
本文介绍了如何限制显示的猕猴桃微调器项目的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前使用的是kivy的Spinner小部件,我想知道是否有一种方法可以限制Spinner显示并滚动查看其余项目的数量. 例如,我使用微调器显示所有月份,因此当我单击微调器时,列表到达窗口的底部.我希望看到5-6个选项,然后滚动查看其余选项.

I am am currently using the spinner widget of kivy and i would like to know if there is a way to limit the number of items the spinner shows and scroll to see the rest. For example, i am using a spinner to display all the months, so when i click the spinner, the list reaches the bottom of the window. I would like to see maybe like 5-6 options and scroll to see the rest of them.

推荐答案

您可以使用

You can use the dropdown_cls.max_size property to specify the maximum height of the drop-down list:

from kivy.base import runTouchApp
from kivy.uix.spinner import Spinner


max = 10
spinner = Spinner(
    text='Values',
    values=(str(n) for n in range(1, 20)),
    size_hint=(None, None),
    size=(100, 44),
    pos_hint={'center_x': .5, 'center_y': 0.9})

spinner.dropdown_cls.max_height = spinner.height* max + max * 4

runTouchApp(spinner)

这篇关于如何限制显示的猕猴桃微调器项目的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆