1 回答
TA贡献1786条经验 获得超13个赞
ScrollView仅当其子项 (the GridLayout) 大于 时才会滚动ScrollView。此外,该行:
height: self.minimum_height
除非您添加以下行,否则将无效:
size_hint_y: None
row_default_height您可以通过为指定 aGridLayout并为 消除 来size_hint_y=None增加绘图的大小FigureCanvasKivyAgg。因此,我建议将您指定ScrollView为:
ScrollView:
id: plot_scroll
do_scroll_y: True
do_scroll_x: False
pos_hint: {"top": .68}
plot_layout: plot_layout
GridLayout:
id: plot_layout
cols: 1
size_hint_y: None
row_default_height: 500 # any default row height that you desire
height: self.minimum_height
然后,使用以下方法添加绘图:
def add_sp_plot(self, date_from, date_to):
# There were too many lines of data handling and plot creating, so I've only left the KivyPart:
# ------- KIVY part ------- KIVY part ------- KIVY part ------- KIVY part ------- #
self.plot_scroll.plot_layout.clear_widgets()
self.plot_scroll.plot_layout.add_widget(FigureCanvasKivyAgg(plt.gcf()))
self.plot_scroll.plot_layout.add_widget(FigureCanvasKivyAgg(plt.gcf()))
self.plot_scroll.plot_layout.add_widget(FigureCanvasKivyAgg(plt.gcf()))
删除size_hint_y=None保留默认值size_hint_yas 1,以便绘图将占用GridLayout分配给它的所有空间 (the row_default_height)。
添加回答
举报