class - Kivy: how to instantiate a dynamic classes in python -


Using KV lang on my Python code, I have taken a hard time trying to instantiate a dynamic class, the following Consider the code:

My test.kv file looks like this:

  & lt; MyPopup @ popup: Title: 'Hello' size_hunt: (1, .6) Grid layout: ID: RouteGrid column: 2 padding: ['8dp', '4dp', '8dp', '4dp'] Difference: '8dp' label: text: 'some text here' button: text: 'OK' On_press: do_something () & lt; MyGrid & gt;: Rows: 1 Button: Text: 'Show Popup' on_press: root.pop.show ()  

Then import Kivy.app into my test.py:

I get the following error: raise Factory Exception ('Uncount Class' <% s>'% name) kivy.factory.FactoryException: Unknown class

< P> Can anyone tell me how to do this properly, what do I remember? If you need more information please let me know Thank you.

Takes a call to the factory before the KV file is loaded, so you want the class to Are not yet in existence.

As long as no class level attribute is required, set self.pop in MyGrid __init __ instead.

You may only include one Python class announcement in it. I usually want to do something which I want to talk to Python, though opinions are different.


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -