我创建了一个基本上是GridLayout的小接口,在其中我放置了一个Button(以及其他东西)调用Popup,其中有一个ScrollView和其他东西。整个代码运行良好,但我试图将GridLayout放在TabbedPanel的一个选项卡中,现在Popup不会滚动。我没有对代码进行任何更改,只是将我的Widget的类更改为TabbedPanel。
我做错了什么?
相关的.py文件:
from kivy.config import Config
Config.set('graphics', 'resizable', 0)
Config.set('graphics', 'position', 'custom')
Config.set('graphics', 'left', 100)
Config.set('graphics', 'top', 100)
Config.write()
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.scatter import Scatter
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.textinput import TextInput
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ListProperty, ObjectProperty, BooleanProperty, StringProperty
from kivy.uix.button import Button
from kivy.uix.filechooser import FileChooser
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.checkbox import CheckBox
from kivy.uix.scrollview import ScrollView
from kivy.uix.progressbar import ProgressBar
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.effects.dampedscroll import DampedScrollEffect
from kivy.uix.spinner import Spinner
from kivy.core.window import Window
from kivy.lang.builder import Builder
from kivy.uix.popup import Popup
class MyWidget(TabbedPanel):
def popupSettings(self, *args):
list_of_choices = []
list_chosen = []
number_content = len(self.spinner_choices)
contentF = ScrollView(do_scroll_x=False, size_hint_y=None, height=400)
content = GridLayout(rows=number_content+1, cols=2, size_hint_y=None, height=self.minimum_height, spacing=30)
for y in self.spinner_choices:
content.add_widget(Label(text=y + " (Current value: {})".format(self.param_values[str(y)]), size_hint_y=None, height=30, size_hint_x=None, width=300))
checkmate = CheckBox(size_hint_y=None, height=30)
self.check_ref[y] = checkmate
content.add_widget(checkmate)
b = Button(text="OK", size_hint_y=None, height=30)
content.add_widget(Label(text="Click here when you are done -> ", size_hint_y=None, height=30))
content.add_widget(b)
contentF.add_widget(content)
p = Popup(title='Choose the parameters you want to change', content=contentF, auto_dismiss=False, size_hint_y=None, height=500, size_hint_x=None, width=500)
b.bind(on_press=lambda *args:self.buttonValidation(p))
p.open()
class TheJamApp(App):
def build(self):
return MyWidget()
if __name__ == "__main__":
Window.size=(768, 930)
TheJamApp().run()
.kv文件:
<MyWidget>:
do_default_tab: False
tab_width: 150
TabbedPanelItem:
text: 'Default'
size_hint_y: None
height: 40
GridLayout:
rows: 8
cols: 1
pos_hint: {'center_x':.5}
height: self.minimum_height
spacing: 20
padding: [20,20]
Label: [...]
TabbedPanelItem:
text: 'Wat'
Button:
size_hint_y: None
height: 40
text:"ok"