1 回答

TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超13個(gè)贊
ScrollView僅當(dāng)其子項(xiàng) (the GridLayout) 大于 時(shí)才會(huì)滾動(dòng)ScrollView。此外,該行:
height: self.minimum_height
除非您添加以下行,否則將無(wú)效:
size_hint_y: None
row_default_height您可以通過(guò)為指定 aGridLayout并為 消除 來(lái)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保留默認(rèn)值size_hint_yas 1,以便繪圖將占用GridLayout分配給它的所有空間 (the row_default_height)。
添加回答
舉報(bào)