QPython或Kivy为Android编程与Python -生产可安装的apk

时间:2022-05-08 20:20:41

Having read several Q&A's on SO, I realize that one has 2 options i.e. QPython and Kivy to do programming for Android, however, apparently both take different approaches. I am trying to validate my understanding and see if I am missing some key piece of information.

在阅读了几个问答之后,我意识到其中有两个选项,即QPython和Kivy为Android编程,然而,很明显,这两个都采用了不同的方法。我试图验证我的理解,看看我是否遗漏了一些关键的信息。

  • QPython allows usage of Kivy library for developing graphical applications
  • QPython允许使用Kivy库开发图形应用程序
  • QPython and Kivy both use SL4A, while QPython has expanded standard SL4A (or it's bindings for Python) by adding some NFC and similar functions
  • QPython和Kivy都使用SL4A,而QPython通过添加一些NFC和类似的函数扩展了标准SL4A(或者是Python的绑定)
  • QPython is used to create python scripts that can use wide range of modules, libraries, but they need QPython installed to be executed on target device. There is no way to package script into an apk.
  • QPython用于创建可以使用各种模块和库的python脚本,但是它们需要安装QPython以在目标设备上执行。无法将脚本打包到apk中。
  • Kivy OTOH, allows developer to write applications that compile to apk, using their cloud based build system (alternative - local build system can be set up on Ubuntu Linux) [However, I noticed that most of the sample apk's that use Kivy are pretty large, in the 40MB range. Did I miss anything ?]
  • Kivy OTOH允许开发人员使用基于云的构建系统(可以在Ubuntu Linux上设置本地构建系统)编写编译成apk的应用程序。我错过什么了吗?
  • QPython apk has 2 version i.e. one for Python-2.7 and another one for Python-3.x. For Kivy, I'm not sure which version it is.
  • QPython apk有两个版本,一个用于Python-2.7,另一个用于Python-3.x。对于Kivy,我不确定是哪个版本。
  • QPython example script (HelloWorld.py) doesn't seem to behave as expected, from latest QPython-3.x from Market, on an Android Kitkat (4.4.2) system. I get the dialog to enter text, but then I expect a Toast to popup, but nothing happens.
  • QPython示例脚本(HelloWorld.py)的行为似乎不像预期的那样,来自最新的QPython-3。x来自市场,在Android Kitkat(4.4.2)系统上。我让对话框输入文本,然后我希望弹出一个吐司,但是什么都没有发生。
  • Get the impression that both QPython and Kivy are developed by a single developer each (or only one person is really active at present), and don't yet have a biggish community. [This is my biggest concern] I notice that there are 3-4 questions with 'qpython' tag on SO, and more than thousand with 'kivy'!
  • 获得这样的印象:QPython和Kivy都是由单个开发人员开发的(或者目前只有一个人非常活跃),并且还没有一个较大的社区。(这是我最大的担心)我注意到在SO上有3-4个带有qpython标签的问题,超过1000个带有kivy !
  • Also get the impression that at this moment Kivy development is somewhat more active (perhaps quite active), but for QPython I don't have a clear picture.
  • 另外,您还会得到这样的印象:Kivy开发现在比较活跃(可能相当活跃),但是对于QPython,我没有一个清晰的概念。
  • Kivy seems to be trying to expand the nature of application that could possibly be written using it, compare to QPython. There are API's like plyer and pyjnius that help expand the possibilities. Perhaps quite significantly, compared to QPython.
  • 与QPython相比,Kivy似乎试图扩展应用程序的本质,可以使用它编写应用程序。有些API像plyer和pyjnius,可以帮助扩展可能性。与QPython相比,这可能相当重要。
  • Both QPython and Kivy seem to be heavily under development. Program (/ script) crashes (/ failures) seem to be reported on both set of tools.
  • QPython和Kivy似乎都在开发中。程序(/脚本)崩溃(/失败)似乎在两组工具中都有报告。

Overall, the opinion as a result (of above points) appears to swing in favour of Kivy, a bit more. Is the understanding correct ? Did I miss any crucial point ? This is not a rhetorical question, and I am looking for factual answers only.

总的来说,(以上几点)的结果是,人们的看法似乎偏向了Kivy,稍微多一点。理解正确吗?我是否漏掉了关键的一点?这不是一个反问句,我只是在寻找事实的答案。

2 个解决方案

#1


14  

QPython allows usage of Kivy library for developing graphical applications

QPython允许使用Kivy库开发图形应用程序

Yes, qpython is an interpreter + associated tools, and has some nice kivy integration. You can't compile the kivy code to a standalone apk with qpython+android alone though.

是的,qpython是一个解释器+相关工具,并且有一些很好的kivy集成。但是,仅凭qpython+android就无法将kivy代码编译成独立的apk。

QPython and Kivy both use SL4A, while QPython has expanded standard SL4A (or it's bindings for Python) by adding some NFC and similar functions

QPython和Kivy都使用SL4A,而QPython通过添加一些NFC和类似的函数扩展了标准SL4A(或者是Python的绑定)

Kivy does not use SL4A. We achieve android api integration mainly through pyjnius, a library for automatically wrapping java classes with python, which lets you call the java api directly. We also have abstracted some standard things to a pythonic interface with plyer.

Kivy不使用SL4A。我们主要通过pyjnius实现android api集成,pyjnius是一个用于用python自动包装java类的库,它允许您直接调用java api。我们还抽象了一些标准的东西到python接口与plyer。

(I saw later that you already have found these)

(我后来看到你已经找到了这些)

QPython is used to create python scripts that can use wide range of modules, libraries, but they need QPython installed to be executed on target device. There is no way to package script into an apk.

QPython用于创建可以使用各种模块和库的python脚本,但是它们需要安装QPython以在目标设备上执行。无法将脚本打包到apk中。

I don't use qpython much, but I think this is correct, although there may be some tools turn scripts to apks in some circumstances (e.g. you could use kivy's build tools if you have a kivy interface, or maybe sl4a has something for this).

我不怎么使用qpython,但我认为这是正确的,尽管在某些情况下,可能会有一些工具将脚本转换为apks(例如,如果您有kivy接口,您可以使用kivy的构建工具,或者sl4a也有类似的工具)。

Kivy OTOH, allows developer to write applications that compile to apk, using their cloud based build system (alternative - local build system can be set up on Ubuntu Linux) [However, I noticed that most of the sample apk's that use Kivy are pretty large, in the 40MB range. Did I miss anything ?]

Kivy OTOH允许开发人员使用基于云的构建系统(可以在Ubuntu Linux上设置本地构建系统)编写编译成apk的应用程序。我错过什么了吗?

We have a basic cloud based build system but nothing else like that right now, almost everyone builds apks on their own machine using our build tools for android. These run on linux or OSX, and can easily be run in a virtual machine if necessary.

我们有一个基本的基于云的构建系统,但是现在没有其他类似的系统,几乎每个人都使用我们的android构建工具在自己的机器上构建apk。它们在linux或OSX上运行,如果需要,可以在虚拟机中轻松运行。

A minimal app has about 7MB APK size due to the necessity of bundling the python interpreter and a lot of modules.

由于需要捆绑python解释器和许多模块,一个最小的应用程序有大约7MB APK大小。

QPython apk has 2 version i.e. one for Python-2.7 and another one for Python-3.x. For Kivy, I'm not sure which version it is.

QPython apk有两个版本,一个用于Python-2.7,另一个用于Python-3.x。对于Kivy,我不确定是哪个版本。

Kivy itself supports python3, but our android build tools only support python2.7 for now.

Kivy本身支持python3,但是我们的android构建工具目前只支持python2.7。

Get the impression that both QPython and Kivy are developed by a single developer each (or only one person is really active at present), and don't yet have a biggish community. [This is my biggest concern] I notice that there are 3-4 questions with 'qpython' tag on SO, and more than thousand with 'kivy'!

获得这样的印象:QPython和Kivy都是由单个开发人员开发的(或者目前只有一个人非常活跃),并且还没有一个较大的社区。(这是我最大的担心)我注意到在SO上有3-4个带有qpython标签的问题,超过1000个带有kivy !

Kivy development is quite active with several regular contributors plus more sporadic ones. You can see for example recent commit activity on github. It's certainly a lot more than a single developer!

Kivy开发非常活跃,有几个固定的贡献者,还有一些零星的贡献者。例如,您可以在github上看到最近的提交活动。它肯定比一个单独的开发人员多得多!

Kivy seems to be trying to expand the nature of application that could possibly be written using it, compare to QPython. There are API's like plyer and pyjnius that help expand the possibilities. Perhaps quite significantly, compared to QPython.

与QPython相比,Kivy似乎试图扩展应用程序的本质,可以使用它编写应用程序。有些API像plyer和pyjnius,可以帮助扩展可能性。与QPython相比,这可能相当重要。

I think qpython includes pyjnius. Not sure about plyer.

我认为qpython包括pyjnius。对从事职业的人不确定。

Both QPython and Kivy seem to be heavily under development. Program (/ script) crashes (/ failures) seem to be reported on both set of tools.

QPython和Kivy似乎都在开发中。程序(/脚本)崩溃(/失败)似乎在两组工具中都有报告。

I'm not sure what you're looking at, but any non-trivial project will have crashes/failures/bugs reported. I don't think kivy is particularly inherently unstable.

我不确定您在看什么,但是任何重要的项目都会报告崩溃/失败/bug。我不认为kivy天生就特别不稳定。

Overall, the opinion as a result (of above points) appears to swing in favour of Kivy, a bit more.

总体而言,这一观点(上述观点)似乎偏向于Kivy,而不是更多。

I would have said that qpython and kivy are quite different things. Qpython lets you write and run scripts, while kivy is a graphical framework and associated tools to create standalone apps. There's some overlap with tasks that could be achieved with both of them, but also plenty of things where they are not both suitable - for instance, I think qpython is probably much more convenient to make quick scripts with no gui for e.g. simple automation (I think this is possible), whereas I think kivy is a far better choice for creating standalone apps with non-trivial guis. Of course you can write kivy code in qpython, as discussed, but this isn't a great user experience for anything non-trivial and you need a desktop/laptop machine anyway to make a standalone apk.

我会说qpython和kivy是完全不同的东西。Qpython允许您编写和运行脚本,而kivy则是创建独立应用程序的图形框架和相关工具。有一些重叠的任务与他们两人能够达到,而且很多东西他们都不合适——例如,我认为qpython可能更方便快速地和没有gui脚本如简单自动化(我认为这是可能的),而我认为kivy是更好的选择用于创建独立的和非平凡的gui应用程序。当然,如前所述,您可以用qpython编写kivy代码,但是对于任何事情来说,这都不是一个很好的用户体验,而且您需要一台桌面/笔记本计算机来构建一个独立的apk。

#2


3  

There are at least two more (though to my knowledge only theoretical) ways of getting Python code running on Android:

至少还有两种方法(据我所知只是理论上的)让Python代码在Android上运行:

  • Use and convert the Java bytecode to Dalvik, as mentioned elsewhere. Unfortunately, not all CPython libraries, e.g. numpy, are available for jython, and if you use Java libraries keep in mind that Android doesn't provide the same ones as e.g. the Desktop JRE
  • 使用jython并将Java字节码转换为Dalvik,如前所述。不幸的是,并非所有的CPython库(例如numpy)都可以用于jython,如果您使用Java库,请记住Android没有提供与Desktop JRE相同的库
  • Use , which generates C++ code from your Python code. Then use the .
  • 使用nuitka,它可以从您的Python代码生成c++代码。然后使用android-ndk。

#1


14  

QPython allows usage of Kivy library for developing graphical applications

QPython允许使用Kivy库开发图形应用程序

Yes, qpython is an interpreter + associated tools, and has some nice kivy integration. You can't compile the kivy code to a standalone apk with qpython+android alone though.

是的,qpython是一个解释器+相关工具,并且有一些很好的kivy集成。但是,仅凭qpython+android就无法将kivy代码编译成独立的apk。

QPython and Kivy both use SL4A, while QPython has expanded standard SL4A (or it's bindings for Python) by adding some NFC and similar functions

QPython和Kivy都使用SL4A,而QPython通过添加一些NFC和类似的函数扩展了标准SL4A(或者是Python的绑定)

Kivy does not use SL4A. We achieve android api integration mainly through pyjnius, a library for automatically wrapping java classes with python, which lets you call the java api directly. We also have abstracted some standard things to a pythonic interface with plyer.

Kivy不使用SL4A。我们主要通过pyjnius实现android api集成,pyjnius是一个用于用python自动包装java类的库,它允许您直接调用java api。我们还抽象了一些标准的东西到python接口与plyer。

(I saw later that you already have found these)

(我后来看到你已经找到了这些)

QPython is used to create python scripts that can use wide range of modules, libraries, but they need QPython installed to be executed on target device. There is no way to package script into an apk.

QPython用于创建可以使用各种模块和库的python脚本,但是它们需要安装QPython以在目标设备上执行。无法将脚本打包到apk中。

I don't use qpython much, but I think this is correct, although there may be some tools turn scripts to apks in some circumstances (e.g. you could use kivy's build tools if you have a kivy interface, or maybe sl4a has something for this).

我不怎么使用qpython,但我认为这是正确的,尽管在某些情况下,可能会有一些工具将脚本转换为apks(例如,如果您有kivy接口,您可以使用kivy的构建工具,或者sl4a也有类似的工具)。

Kivy OTOH, allows developer to write applications that compile to apk, using their cloud based build system (alternative - local build system can be set up on Ubuntu Linux) [However, I noticed that most of the sample apk's that use Kivy are pretty large, in the 40MB range. Did I miss anything ?]

Kivy OTOH允许开发人员使用基于云的构建系统(可以在Ubuntu Linux上设置本地构建系统)编写编译成apk的应用程序。我错过什么了吗?

We have a basic cloud based build system but nothing else like that right now, almost everyone builds apks on their own machine using our build tools for android. These run on linux or OSX, and can easily be run in a virtual machine if necessary.

我们有一个基本的基于云的构建系统,但是现在没有其他类似的系统,几乎每个人都使用我们的android构建工具在自己的机器上构建apk。它们在linux或OSX上运行,如果需要,可以在虚拟机中轻松运行。

A minimal app has about 7MB APK size due to the necessity of bundling the python interpreter and a lot of modules.

由于需要捆绑python解释器和许多模块,一个最小的应用程序有大约7MB APK大小。

QPython apk has 2 version i.e. one for Python-2.7 and another one for Python-3.x. For Kivy, I'm not sure which version it is.

QPython apk有两个版本,一个用于Python-2.7,另一个用于Python-3.x。对于Kivy,我不确定是哪个版本。

Kivy itself supports python3, but our android build tools only support python2.7 for now.

Kivy本身支持python3,但是我们的android构建工具目前只支持python2.7。

Get the impression that both QPython and Kivy are developed by a single developer each (or only one person is really active at present), and don't yet have a biggish community. [This is my biggest concern] I notice that there are 3-4 questions with 'qpython' tag on SO, and more than thousand with 'kivy'!

获得这样的印象:QPython和Kivy都是由单个开发人员开发的(或者目前只有一个人非常活跃),并且还没有一个较大的社区。(这是我最大的担心)我注意到在SO上有3-4个带有qpython标签的问题,超过1000个带有kivy !

Kivy development is quite active with several regular contributors plus more sporadic ones. You can see for example recent commit activity on github. It's certainly a lot more than a single developer!

Kivy开发非常活跃,有几个固定的贡献者,还有一些零星的贡献者。例如,您可以在github上看到最近的提交活动。它肯定比一个单独的开发人员多得多!

Kivy seems to be trying to expand the nature of application that could possibly be written using it, compare to QPython. There are API's like plyer and pyjnius that help expand the possibilities. Perhaps quite significantly, compared to QPython.

与QPython相比,Kivy似乎试图扩展应用程序的本质,可以使用它编写应用程序。有些API像plyer和pyjnius,可以帮助扩展可能性。与QPython相比,这可能相当重要。

I think qpython includes pyjnius. Not sure about plyer.

我认为qpython包括pyjnius。对从事职业的人不确定。

Both QPython and Kivy seem to be heavily under development. Program (/ script) crashes (/ failures) seem to be reported on both set of tools.

QPython和Kivy似乎都在开发中。程序(/脚本)崩溃(/失败)似乎在两组工具中都有报告。

I'm not sure what you're looking at, but any non-trivial project will have crashes/failures/bugs reported. I don't think kivy is particularly inherently unstable.

我不确定您在看什么,但是任何重要的项目都会报告崩溃/失败/bug。我不认为kivy天生就特别不稳定。

Overall, the opinion as a result (of above points) appears to swing in favour of Kivy, a bit more.

总体而言,这一观点(上述观点)似乎偏向于Kivy,而不是更多。

I would have said that qpython and kivy are quite different things. Qpython lets you write and run scripts, while kivy is a graphical framework and associated tools to create standalone apps. There's some overlap with tasks that could be achieved with both of them, but also plenty of things where they are not both suitable - for instance, I think qpython is probably much more convenient to make quick scripts with no gui for e.g. simple automation (I think this is possible), whereas I think kivy is a far better choice for creating standalone apps with non-trivial guis. Of course you can write kivy code in qpython, as discussed, but this isn't a great user experience for anything non-trivial and you need a desktop/laptop machine anyway to make a standalone apk.

我会说qpython和kivy是完全不同的东西。Qpython允许您编写和运行脚本,而kivy则是创建独立应用程序的图形框架和相关工具。有一些重叠的任务与他们两人能够达到,而且很多东西他们都不合适——例如,我认为qpython可能更方便快速地和没有gui脚本如简单自动化(我认为这是可能的),而我认为kivy是更好的选择用于创建独立的和非平凡的gui应用程序。当然,如前所述,您可以用qpython编写kivy代码,但是对于任何事情来说,这都不是一个很好的用户体验,而且您需要一台桌面/笔记本计算机来构建一个独立的apk。

#2


3  

There are at least two more (though to my knowledge only theoretical) ways of getting Python code running on Android:

至少还有两种方法(据我所知只是理论上的)让Python代码在Android上运行:

  • Use and convert the Java bytecode to Dalvik, as mentioned elsewhere. Unfortunately, not all CPython libraries, e.g. numpy, are available for jython, and if you use Java libraries keep in mind that Android doesn't provide the same ones as e.g. the Desktop JRE
  • 使用jython并将Java字节码转换为Dalvik,如前所述。不幸的是,并非所有的CPython库(例如numpy)都可以用于jython,如果您使用Java库,请记住Android没有提供与Desktop JRE相同的库
  • Use , which generates C++ code from your Python code. Then use the .
  • 使用nuitka,它可以从您的Python代码生成c++代码。然后使用android-ndk。