{"id":90,"date":"2023-05-25T17:50:57","date_gmt":"2023-05-25T09:50:57","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=90"},"modified":"2023-05-25T17:50:57","modified_gmt":"2023-05-25T09:50:57","slug":"pyqt5%e6%89%93%e5%8c%85apk%e6%9c%89%e9%82%a3%e4%ba%9b%e4%bc%98%e5%8a%bf%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2023\/sjapp\/90\/","title":{"rendered":"pyqt5\u6253\u5305apk\u6709\u90a3\u4e9b\u4f18\u52bf\uff1f"},"content":{"rendered":"<p>PyQt5\u662fPython\u8bed\u8a00\u4e2d\u7684GUI\u5de5\u5177\u5305\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efa\u51fa\u6f02\u4eae\u7684\u56fe\u5f62\u754c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u800c\u6253\u5305\u6210apk\u6587\u4ef6\u5219\u662f\u5c06PyQt5\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u3002\u672c\u6587\u5c06\u4ecb\u7ecdPyQt5\u6253\u5305apk\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n<p>\u4e00\u3001\u539f\u7406\u4ecb\u7ecd<\/p>\n<p>\u5728\u5b89\u5353\u7cfb\u7edf\u4e2d\uff0c\u5e94\u7528\u7a0b\u5e8f\u662f\u4ee5Java\u4ee3\u7801\u7684\u5f62\u5f0f\u5b58\u5728\u7684\uff0c\u56e0\u6b64\u8981\u5c06PyQt5\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u5c06Python\u4ee3\u7801\u8f6c\u5316\u4e3aJava\u4ee3\u7801\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u9700\u8981\u7528\u5230\u4e00\u4e2a\u5de5\u5177\u2014\u2014PyQt5\u7684\u6253\u5305\u5de5\u5177PyInstaller\u3002PyInstaller\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u6253\u5305\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4e5f\u53ef\u4ee5\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u5e93\u6587\u4ef6\u4f9b\u5176\u4ed6\u7a0b\u5e8f\u8c03\u7528\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528PyInstaller\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u4e8c\u3001\u8be6\u7ec6\u6b65\u9aa4<\/p>\n<p>1. \u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6<\/p>\n<p>\u5728\u5f00\u59cb\u6253\u5305\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\uff1a<\/p>\n<p>&#8211; Python 3.x\uff1a\u7528\u4e8e\u7f16\u5199PyQt5\u5e94\u7528\u7a0b\u5e8f\u7684Python\u73af\u5883\u3002<\/p>\n<p>&#8211; Android SDK\uff1a\u7528\u4e8e\u751f\u6210\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u6587\u4ef6\u3002<\/p>\n<p>&#8211; JDK\uff1aJava\u5f00\u53d1\u5de5\u5177\u5305\uff0c\u7528\u4e8e\u5c06Python\u4ee3\u7801\u8f6c\u5316\u4e3aJava\u4ee3\u7801\u3002<\/p>\n<p>&#8211; PyInstaller\uff1a\u7528\u4e8e\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>2. \u7f16\u5199PyQt5\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u6253\u5305\u4e4b\u524d\uff0c<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/17\/17\/27337920245.jpg\" \/><\/figure>\n<\/p>\n<p>\u9700\u8981\u5148\u7f16\u5199\u597dPyQt5\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\uff0c\u8bfb\u8005\u53ef\u4ee5\u53c2\u8003\u5176\u4ed6\u6559\u7a0b\u8fdb\u884c\u5b66\u4e60\u3002<\/p>\n<p>3. \u6253\u5305\u4e3a\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>pyinstaller -w -F main.py<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0c`-w`\u53c2\u6570\u8868\u793a\u4e0d\u4f7f\u7528\u63a7\u5236\u53f0\u7a97\u53e3\uff0c`-F`\u53c2\u6570\u8868\u793a\u5c06\u6240\u6709\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c`main.py`\u662f\u4f60\u7684\u4e3b\u7a0b\u5e8f\u6587\u4ef6\u540d\u3002\u6267\u884c\u5b8c\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a`dist`\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u53ef\u6267\u884c\u6587\u4ef6\u548c\u5176\u4ed6\u6240\u9700\u6587\u4ef6\u3002<\/p>\n<p>4. \u6253\u5305\u4e3aapk\u6587\u4ef6<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>buildozer init<\/p>\n<p>&#8220;`<\/p>\n<p>\u8be5\u547d\u4ee4\u4f1a\u751f\u6210\u4e00\u4e2a`buildozer.spec`\u6587<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-1464.html\">vue2\u9879\u76ee\u6253\u5305\u6210app<\/a>\u4ef6\uff0c\u6253\u5f00\u8be5\u6587\u4ef6\uff0c\u4fee\u6539\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p># (str) Title of your application<\/p>\n<p>title = My Application<\/p>\n<p># (str) Package name<\/p>\n<p>package.name = myapp<\/p>\n<p># (str) Package domain (needed for android\/ios packaging)<\/p>\n<p>package.domain = com.myapp<\/p>\n<p># (str) Source code where the main.py live<\/p>\n<p>source.dir = .<\/p>\n<p># (list) Application requirements<\/p>\n<p>requirements = python3,kivy,pyjnius,android,pyqt5<\/p>\n<p># (str) Application versioning (method 1)<\/p>\n<p>version = 0.1<\/p>\n<p># (list) Permissions<\/p>\n<p>android.permissions = INTERNET<\/p>\n<p># (str) Android SDK version to use<\/p>\n<p>android.sdk = 27<\/p>\n<p># (str) Android NDK version to use<\/p>\n<p>android.ndk = 17c<\/p>\n<p># (str) Android SDK path<\/p>\n<p>android.sdk_path = \/path\/to\/android\/sdk<\/p>\n<p># (str) Android NDK path<\/p>\n<p>android.ndk_path = \/path\/to\/android\/ndk<\/p>\n<p># (str) Android API to use<\/p>\n<p>android.api = 27<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0c`title`\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\uff0c`package.name`\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u540d\uff0c`package.domain`\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u7684\u57df\u540d\uff0c`source.dir`\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u7684\u6e90\u4ee3\u7801\u76ee\u5f55\uff0c`requirements`\u8868\u793a\u6240\u9700\u7684Python\u5e93\uff0c`version`\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u7684\u7248\u672c\u53f7\uff0c`android.permissions`\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u7684\u6743\u9650\uff0c`android.sdk`\u8868\u793a\u4f7f\u7528\u7684\u5b89\u5353SDK\u7248\u672c\uff0c`android.ndk`\u8868\u793a\u4f7f\u7528\u7684\u5b89\u5353NDK\u7248\u672c\uff0c`android.sdk_path`\u8868\u793a\u5b89\u5353SDK\u76ee\u5f55\u7684\u8def\u5f84\uff0c`android.ndk_path`\u8868\u793a\u5b89\u5353NDK\u76ee\u5f55\u7684\u8def\u5f84\uff0c`android.api`\u8868\u793a\u4f7f\u7528\u7684<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-2733.html\">h5\u751f\u6210app<\/a>\u5b89\u5353API\u7248\u672c\u3002<\/p>\n<p>\u4fee\u6539\u5b8c\u540e\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>buildozer android debug<\/p>\n<p>&#8220;`<\/p>\n<p>\u8be5\u547d\u4ee4\u4f1a\u81ea\u52a8\u5c06Python\u4ee3\u7801\u8f6c\u5316\u4e3aJava\u4ee3\u7801\uff0c\u5e76\u5c06\u6240\u6709\u6587\u4ef6\u6253\u5305\u6210apk\u6587\u4ef6\u3002\u6253\u5305\u5b8c\u6210\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a`bin`\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u6253\u5305\u597d\u7684apk\u6587\u4ef6\u3002<\/p>\n<p>\u4e09\u3001\u603b\u7ed3<\/p>\n<p>\u901a\u8fc7PyInstaller\u548cbuildozer\u5de5\u5177\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06PyQt5\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\u3002\u867d\u7136\u6253\u5305\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\uff0c\u4f46\u53ea\u8981\u8010\u5fc3\u8c03\u8bd5\uff0c\u5c31\u80fd\u987a\u5229\u5b8c\u6210\u6253\u5305\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PyQt5\u662fPython\u8bed\u8a00\u4e2d\u7684GUI\u5de5\u5177\u5305\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efa\u51fa\u6f02\u4eae\u7684\u56fe\u5f62\u754c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u800c\u6253\u5305\u6210apk\u6587\u4ef6\u5219\u662f\u5c06PyQt5\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u3002\u672c\u6587\u5c06\u4ecb\u7ecdPyQt5\u6253\u5305apk\u7684\u539f\u7406<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[211,210,193,11,81],"topic":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-sjapp","tag-app","tag-ipaapp","tag-193","tag-11","tag-81"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":0,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=90"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}