First, we import Kivy, and check if the current installed version will be enough for our application. If not, an exception will be automatically fired, and prevent your application to crash in runtime. You can read the documentation of kivy.require() function for more information.首先,我们导入Kivy,然后检查最近被安装的版本是否支持我们的应用程序。如果不支持,一个异常江北自动抛出,然后保护你的应用程序在运行时崩溃。你可以阅读有关kivy.requier()函数的文档来获得更多的信息。 We import the App class, to be able to subclass it. By subclassing this class, your own class gains several features that we already developed for you to make sure it will be recognized by Kivy.我们引入App类,以便能够继承它。通过继承这个类,你自己的类获得几个我们已经为你开发出来用于确认已经被Kivy认识到得特性。
Next, we import the Button class, to be able to create an instance of a button with a custom label.下一步,我们导入Button类,以能够创建一个伴随有一个label的按钮的实例。
Then, we create our application class, based on the App class. We extend the build() function to be able to return an instance of Button. This instance will be used as the root of the widget tree (because we returned it).然后,我们创建我们的基于App类的应用程序类。我们扩展build()方法以便返回一个Button的实例.这个实例被用于作为widget树的根(因为我们返回它).
Finally, we call run() on our application instance to launch the Kivy process with our application inside.最后,我们再我们的应用程序实例中调用run()以启动Kivy在内部处理我们的应用程序.