ScrollViewを試していたのですが
なかなかサイトの通りにやってもうまく表示されず
pythonで雄一うまくいったのが以下のコードでした
python
1class MyApp(App): 2 def boo(self,instance): 3 print("aaaaaaaaaaaaaa"+instance.text) 4 def build(self): 5 6 layout = BoxLayout(size_hint=(1, None)) 7 layout.orientation = 'vertical' 8 9 layout.bind(minimum_height=layout.setter('height')) 10 for i in range(30): 11 data = 'test' + str(i) 12 btn = Button(text=data, height=30, size_hint=(1, None), on_press=self.boo) 13 layout.add_widget(btn) 14 15 root = ScrollView(size_hint=(1, None), size=( 16 Window.width, Window.height)) 17 18 root.add_widget(layout) 19 20 return root 21"""
しかしkvファイルのほうでScrollViewを書きたいのですがうまくいきません
kvファイルでは何が原因でおかしくなっているのでしょうか?
症状は下にボタンが一個表示されるのみです 一切スクロースされません
自分なりにkvにしたコード
kv
1<MainScreen>: 2 BoxLayout: 3 ScrollView: 4 size_hint:(1, None) 5 BoxLayout: 6 size_hint_y: None 7 orientation: "vertical" 8 Label: 9 size_hint_y: None 10 text: "1111" 11 height: 500 12 Button: 13 size_hint_y: None 14 text: "2222" 15 Label: 16 size_hint_y: None 17 text: "3333" 18 height: 200 19 Button: 20 size_hint_y: None 21 text: "4444" 22 height: 300 23 Label: 24 size_hint_y: None 25 text: "1111" 26 height: 500 27 Button: 28 size_hint_y: None 29 text: "2222" 30 Label: 31 size_hint_y: None 32 text: "3333" 33 height: 200 34 Button: 35 size_hint_y: None 36 text: "4444" 37 height: 300
python
1class MainScreen(BoxLayout): 2 pass 3 4Builder.load_file('scr.kv') 5 6class MyApp(App): 7 8 def build(self): 9 10 self.title = 'テスト' 11 return MainScreen()
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。