私はこのコードを持っています。アコーディオンアイテムの数を特定の量を超えて増やすと、アプリは混乱します。gridLayoutバージョン(コメントアウト)は期待どおりに機能します。問題のある地域は、こことそこの間にあります。
from kivy.app import App
from kivy.uix.spinner import Spinner, SpinnerOption
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.accordion import Accordion, AccordionItem
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout
from kivy.core.window import Window
class MusicController(App):
def build(self):
b = BoxLayout(orientation='vertical')
top = Spinner(text = '12', values = ["Songs","Artist","Playlist","Search"], background_color = (.3,.2,.5,1), size_hint_y = 0.1)
#< HERE >#
items = Accordion(orientation='vertical')
for x in xrange(30):
item = AccordionItem(title='Title %d' % x)
buttons = BoxLayout()
buttons.add_widget(Button(text='Play'))
buttons.add_widget(Button(text='Pause'))
buttons.add_widget(Button(text='Pause'))
item.add_widget(buttons)
items.add_widget(item)
#~ items = GridLayout(cols=1, spacing=10, size_hint_y=None)
#~ items.bind(minimum_height=items.setter('height'))
#~ for i in range(30):
#~ btn = Button(text=str(i),
#< THERE >#
sv = ScrollView(do_scroll_x = False)
sv.add_widget(items)
now_playing = BoxLayout(size_hint_y = 0.1)
for widget in ["Prev","Play","Pause","Next","NP"]:
now_playing.add_widget(Button(text=widget))
b.add_widget(top)
b.add_widget(sv)
b.add_widget(now_playing)
return b
if __name__ == '__main__':
MusicController().run()