How to limit the number of displayed kivy spinner items

烂漫一生 提交于 2019-12-24 22:42:08

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/45000831/how-to-limit-the-number-of-displayed-kivy-spinner-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!