简体   繁体   English

pyqtdeploy:如何为 Android 设置应用程序图标?

[英]pyqtdeploy: how to set application icon for Android?

I'm following this howto to build an Android application with Python3 and Qt5.我正在按照方法使用 Python3 和 Qt5 构建 Android 应用程序。 Nearly everything works fine but somehow I cannot find out how to set the application icon.几乎一切正常,但不知何故我无法找到如何设置应用程序图标。 In the documentation I could not find anything neither..文档中我也找不到任何东西..

And just in case you know PyQtDeploy anyway.. how do I set the build mode from debug to release ?以防万一你知道 PyQtDeploy ......我如何设置从debugrelease的构建模式?

Backround:背景:

pyqtdeploy-build creates the whole build-folder for Android (which contains all resources and AndroidManifest.xml ) from scratch. pyqtdeploy-build从头开始为 Android 创建整个构建文件夹(其中包含所有资源和AndroidManifest.xml )。 Up to now I did not find a way to tell which icon to use.到目前为止,我还没有找到一种方法来判断要使用哪个图标。 I would expect an option in the pyqtdeploy interface but there seems to be none..我希望 pyqtdeploy 界面中有一个选项,但似乎没有..

Edit编辑

I have never tried it but @Fred in comment above mentioned this way in Qt Creator - maybe it will work我从未尝试过,但上面评论中的@Fred在 Qt Creator 中提到了这种方式- 也许它会起作用

Edit end编辑结束

PyQtDeploy is designed for Python code and resources management. PyQtDeploy 专为 Python 代码和资源管理而设计。 App icon is an Android framework thing, so you have to do it Android way - create resource in res folder and reference it in Android manifest .应用程序图标是 Android 框架的东西,所以你必须用 Android 的方式来做 - 在res文件夹中创建资源并在Android manifest引用它。

You can automate the process though - you may create simple bash script that does the thing or one more Python build script with the same purpose - it takes icon from your location moves it to res folder and alters previously generated manifest with the correct reference in form of android:icon="@drawable/your_logo_name" .不过,您可以自动执行该过程 - 您可以创建简单的 bash 脚本来执行此操作,或者创建一个具有相同目的的 Python 构建脚本 - 它会将您所在位置的图标移动到res文件夹,并使用正确的引用形式更改先前生成的清单android:icon="@drawable/your_logo_name"

At least I was doing it like that.至少我是这样做的。

And as a recommendation - if you want to use Python to develop under Android(and cross platform) use Kivy it is much more mature, supportable and complete with much bigger community.并且作为建议 - 如果您想使用 Python 在 Android(和跨平台)下进行开发,请使用Kivy,它更加成熟、可支持并且具有更大的社区。 It is much faster and has more libs also.它要快得多,也有更多的库。

Hope it helps.希望能帮助到你。

In Android you find one res name folder if not create it their and refer to manifest file .在 Android 中,您会找到一个 res 名称文件夹,如果不创建它们并参考清单文件。

Now you have to put icon inside a drawable folder which is inside res folder现在您必须将图标放在 res 文件夹内的 drawable 文件夹中

Your path follow look like :res>>>>drawable >>>icon.png你的路径如下:res>>>>drawable >>>icon.png

在此处输入图片说明

In case of Kivy it become twice eaiser在 Kivy 的情况下,它变得容易两倍

Your icon path needs to be either absolute or relative to your application file.您的图标路径需要是绝对的或相对于您的应用程序文件的路径。 So if your directory structure looks like this:因此,如果您的目录结构如下所示:

my_app/ ├── app.py └── things └── images └── my_icon.png my_app/ ├── app.py └──东西└──图像└── my_icon.png

class MyApp:
    def build(self):
        self.icon = r'C:\Users\you\path\to\my_app\things\images\my_icon.png'
self.icon = r'things\images\my_icon.png'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM