SaikiHanee SaikiHanee - 4 years ago 342
Python Question

Add a ScrollView to kivy Popup

I am trying to add a ScrollView to a Popup which opens when button is clicked on the main interface. But the scrollview is not displaying the content properly. How can I fix this?

from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.uix.scrollview import ScrollView
from import App
from kivy.core.window import Window

def btn_clicked(instance):
layout_popup = GridLayout(cols=1, spacing=10, size_hint_y=None)

for i in range(0, 15):
btn1 = Button(text=str(i), id=str(i))

root = ScrollView(size_hint=(1, None), size=(Window.width, Window.height))
popup = Popup(title='Numbers', content=root, size_hint=(1, 1))

class TutorialApp(App):
def build(self):
g = GridLayout(cols=1)
btn = Button(text='Click')
return g


Answer Source

Pass size_hint_y=None to the button constructor and it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download