I want to access the version number of my app outside the main.py. Is this possible to do this in foo.py without import main.py
? What I tried:
main.py:
from kivy.app import App
__version__ = '0.4.0'
class KanjiOriginApp(App):
app_version = StringProperty(__version__)
foo.py:
from kivy.app import App
print(App.app_version)
But this results in a: AttributeError: type object 'App' has no attribute 'app_version'
.
您需要App.get_running_app().app_version
-StringProperty提供实例级的行为,它不会修改App本身的类定义。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.