Как добавлять графики в макеты после нажатия кнопки в KivyMD? - PullRequest
0 голосов
/ 06 мая 2020

У меня проблема с добавлением графиков в макеты. Я понятия не имею, как связать кнопку с моими BoxLayouts. Я дал каждому BoxLayout специальный id , но я не знаю, что делать сейчас. Я просто хочу показать несколько графиков после нажатия кнопки. Вот мой код:

import kivy
from kivy.lang import Builder

from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg
from kivymd.app import MDApp
import matplotlib.pyplot as plt

KV = '''
GridLayout:
    cols:2

    BoxLayout:
        orientation: "vertical"
        id: plot1
        MDLabel:
            text:"I want to put a plot here"
            halign: "center"

    BoxLayout:
        orientation: "vertical"
        id: plot2
        MDLabel:
            text:"I want to put a plot here"
            halign: "center"

    BoxLayout:
        orientation: "vertical"
        id: plot3
        MDLabel:
            text:"I want to put a plot here"
            halign: "center"


    FloatLayout:
        MDFloatingActionButton:
            pos_hint: {'center_x': .9, 'center_y': .15}
            icon:"chart-bell-curve-cumulative"
            on_release: app.show_plot()
'''

class Main(MDApp):

    def build(self):
        return Builder.load_string(KV)

    def show_plot(self):
        #some plots to show
        pass

Main().run()

Буду благодарен за любой совет по этой проблеме.

...