0

I'm working on a Kivy app which should generate plots when the user clicks on an item from a menu. When the user clicks the item, it opens a new screen which should generate the plot. My problem is that I can't seem to get Kivy to show the plot. My code executes without errors so I'm not sure where I'm going wrong.

I've looked for questions on this issue and the best I could find is here (Real-time plotting using matplotlib and kivy in Python) but that didn't work for me.

I also have a secondary question about re-defining the on_enter method of the Screen class so that it can use the App method for creating the plot. Is this possible?

Python code (function defined as part of the App class)

def grp_enter(self):
        grid = GridLayout(rows = 1, cols = 1)
        #grid.add_widget(FigureCanvasKivyAgg(plt.gcf())) should have prepared a canvas but one didn't appear
        self.track_instance.associations() # generates the plot

KV code

<GroupScreen>:
    on_enter: app.grp_enter()
    name: 'groups_screen'

    Button:
        on_release:
            app.root.transition = SlideTransition(direction = "right")
            app.root.current = 'main'
        text: 'back to the home screen'
        font_size: 50
kynnemall
  • 855
  • 9
  • 26

1 Answers1

0

I could be wrong as I haven't been able to test your code but I believe that your screen doesn't get updated when you try to display your plot. You should try to use the schedule function: clock.schedule_once(function_showing_plot).

So in your grp_enter function, you would call your track_instance.associations() function as such: clock.schedule_once(track_instance.associations)

Hope this helps.

Leo Aimone
  • 55
  • 4