Skip to content
Advertisement

How to put a Graph into a Screen(Manager) with kivy

I have 3 Screens in my kivy application and in the second screen i want to put a graph which is a widget. I have my own class for this graph. The goal is do display 3 separate graphs in one screen.

I’m pretty sure there is some problem with the id from the class Graph. I tried to use self.ids.get_screen or just copying everything from the class Graph to the class SecondScreen. Sometimes i get a different error but normally this one.

Can maybe someone explain IDs to me? I think i am very confused what to do when i have to use an id from one class in another. Sadly the other questions with the same error didn’t really help

Thanks a lot for helping!

This is my error:

JavaScript

This are some code snippets:

python code:

JavaScript

kivy code:

JavaScript

EDIT: ok i figured some stuff out. The ids library contains those ids

{‘ActionBar’: <WeakProxy to <kivy.factory.SomeMenu_ActionBar object at 0x7f9ffc677c10>>, ‘sm’: <WeakProxy to <kivy.uix.screenmanager.ScreenManager object at 0x7f9ff4175820>>}

so i think i need to add the graph id there too. Still not sure how, but im still on it.

I deleted the Graph: from Second Screen. Added Graph: with an id to ScreenManager:

JavaScript

Now i have this AttributeError:

AttributeError: ‘NoneType’ object has no attribute ‘ids’

Advertisement

Answer

Ok i found the answer

Here is only the changed parts of my code: python file:

JavaScript

kv-file:

JavaScript

I dont need a definition of Graph in the kv-File since everything is handled in the python file

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement