问题
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