{"id":24743,"date":"2023-12-20T11:06:31","date_gmt":"2023-12-20T03:06:31","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=24743"},"modified":"2023-12-20T11:06:31","modified_gmt":"2023-12-20T03:06:31","slug":"pyton%e5%88%b6%e4%bd%9c%e5%ae%89%e5%8d%93app%e6%96%b9%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appkaifa\/24743.html","title":{"rendered":"pyton\u5236\u4f5c\u5b89\u5353app\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>Python\u662f\u4e00\u95e8\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u3001Web\u5f00\u53d1\u3001\u81ea\u52a8\u5316\u811a\u672c\u7b49\u9886\u57df\u3002Python\u62e5\u6709\u4e30\u5bcc\u7684\u7b2c\u4e09\u65b9\u5e93\u548c\u5f00\u6e90\u5de5\u5177\uff0c\u4f7f\u5f97\u5176\u5728\u79fb\u52a8\u5e94\u7528\u5f00\u53d1\u9886\u57df\u4e5f\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002Python\u53ef\u4ee5\u901a\u8fc7Kivy\u3001PyQt5\u3001Tkinter\u7b49\u6846\u67b6\u6765\u5f00\u53d1\u8de8\u5e73\u53f0\u7684\u5b89\u5353\u5e94\u7528\u3002<\/p>\n<p>Ki<a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353app\u5f00\u53d1\u5de5\u5177<\/a>vy\u662fPython\u7f16\u5199\u7684\u8de8\u5e73\u53f0\u7684\u5f00\u6e90\u6846\u67b6\uff0c\u652f\u6301Windows\u3001MacOS\u3001Linux\u3001iOS\u3001Android\u7b49\u64cd\u4f5c\u7cfb\u7edf\u3002Kivy\u901a\u8fc7\u81ea\u5df1\u7684\u8bed\u8a00Kv\u6765\u63cf\u8ff0\u5e94\u7528\u754c\u9762\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7Python\u4ee3\u7801\u4e0eKv\u8bed\u8a00\u642d\u914d\u6765\u6784\u5efa\u5e94\u7528\u3002Kivy\u63d0\u4f9b\u4e86\u73b0\u6210\u7684\u7ec4\u4ef6\uff08Widget\uff09\u5982Label\u3001Button\u3001Image\u7b49\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u57fa\u4e8e\u7ec4\u4ef6\u5feb\u901f\u5f00\u53d1\u5e94\u7528\u3002<\/p>\n<p>\u4f7f\u7528Kivy\u5f00\u53d1\u5b89\u5353\u5e94\u7528\u7684\u5927\u81f4\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>1. \u5b89\u88c5Kivy\u7684\u73af\u5883\uff1b<\/p>\n<p>2. \u4f7f\u7528Kivy\u8bed\u8a00\u63cf\u8ff0\u5e94\u7528UI\uff1b<\/p>\n<p>3. \u5229\u7528Python\u4ee3\u7801\u7ed1\u5b9aKivy\u7ec4\u4ef6\u4e0e\u51fd\u6570\uff1b<\/p>\n<p>4. \u6700\u7ec8\u5c06Python\u4ee3\u7801\u7f16\u8bd1\u4e3aapk\u5305\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4f7f\u7528Kivy\u5f00\u53d1\u201cHello World\u201d\u5e94\u7528\u7684\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n<p>main.py\uff1a<\/p>\n<p>&#8220;`python<\/p>\n<p>from kivy.app import<a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353app<\/a> App<\/p>\n<p>from kivy.uix.label import Label<\/p>\n<p>class HelloWorld(App):<\/p>\n<p>    def build(self):<\/p>\n<p>        return Label(text=&#8217;Hello<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-04\/07\/10\/24431743787.jpg\" \/><\/figure>\n<\/p>\n<p> World!&#8217;)<\/p>\n<p>if __name__ == &#8216;__main__&#8217;:<\/p>\n<p>    HelloWorld().run()<\/p>\n<p>&#8220;`<\/p>\n<p>hello_world.kv\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>Label:<\/p>\n<p>    text: &#8216;Hello World!&#8217;<\/p>\n<p>&#8220;`<\/p>\n<p>\u53ef\u4ee5\u770b\u51fa\uff0c\u6211\u4eec\u4f7f\u7528Python\u4ee3\u7801\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a HelloWorld \u7684\u5e94\u7528\u7c7b\uff0c\u5728\u8be5\u7c7b\u4e2d\u7684 build \u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u8fd4\u56de\u4e86\u4e00\u4e2a Label \u5bf9\u8c61\uff0c\u5e76\u5c06\u5176 text \u5c5e\u6027\u8bbe\u7f6e\u4e3a&#8217;Hello World!&#8217;\u3002\u540c\u65f6\uff0c\u6211\u4eec\u8fd8\u901a\u8fc7\u5b9a\u4e49kv\u6587\u4ef6\u6765\u63cf\u8ff0\u5e94\u7528\u754c\u9762\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u5c06Python\u4ee3\u7801\u8f6c\u5316\u4e3a\u5b89\u5353\u79fb\u52a8\u5e94\u7528\u3002\u5176\u4e2d\uff0cPython-for-Android\u662f\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u5b83\u53ef\u5c06Python\u4ee3\u7801\u548cKivy\u5e94\u7528\u81ea\u52a8\u6253\u5305\u4e3a\u5b89\u5353\u5e94\u7528\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528buildozer\u6765\u6253\u5305\u6211\u4eec\u7684\u5e94\u7528\u4ee3\u7801\u3002<\/p>\n<p>\u901a\u8fc7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5c06 HelloWorld \u5e94\u7528\u7f16\u8bd1\u4e3a\u4e00\u4e2aapk\u6587\u4ef6\u3002<\/p>\n<p>&#8220;`sh<\/p>\n<p>buildozer android debug<\/p>\n<p>&#8220;`<\/p>\n<p>\u603b\u4e4b\uff0c\u4f7f\u7528Python\u7f16\u5199\u5b89\u5353\u5e94\u7528\u7684\u4f18\u52bf\u5728\u4e8e\u53ef\u4ee5\u4f7f\u7528Python\u5f3a\u5927\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u5e76\u4e14\u719f\u6089Python\u7684\u5f00\u53d1\u8005\u53ef\u4ee5\u975e\u5e38\u5feb\u901f\u5730\u8fdb\u884c\u5b89\u5353\u5e94\u7528\u7684\u5f00\u53d1\u3002\u4f7f\u7528Kivy\u6846\u67b6\u80fd\u591f\u5feb\u901f\u8de8\u5e73\u53f0\u5f00\u53d1\u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u662f\u4e00\u95e8\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u3001Web\u5f00\u53d1\u3001\u81ea\u52a8\u5316\u811a\u672c\u7b49\u9886\u57df\u3002Python\u62e5\u6709\u4e30\u5bcc\u7684\u7b2c\u4e09\u65b9\u5e93\u548c\u5f00\u6e90\u5de5\u5177\uff0c\u4f7f\u5f97\u5176\u5728\u79fb\u52a8\u5e94\u7528\u5f00\u53d1\u9886\u57df\u4e5f\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002Python\u53ef\u4ee5\u901a\u8fc7Kivy\u3001P<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[980,29457,29458,789,1426],"class_list":{"0":"post-24743","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-appkaifa","7":"tag-980","8":"tag-app","10":"tag-789","11":"tag-1426"},"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/24743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=24743"}],"version-history":[{"count":1,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/24743\/revisions"}],"predecessor-version":[{"id":24756,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/24743\/revisions\/24756"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=24743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=24743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=24743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}