{"id":11466,"date":"2023-10-19T15:45:21","date_gmt":"2023-10-19T07:45:21","guid":{"rendered":"https:\/\/app.60day.cn\/appday\/?p=11466"},"modified":"2023-10-19T15:45:21","modified_gmt":"2023-10-19T07:45:21","slug":"nanui%e6%89%93%e5%8c%85exe%e6%93%8d%e4%bd%9c%e6%b5%81%e7%a8%8b%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/app.60day.cn\/appday\/kaifaexe\/11466\/","title":{"rendered":"nanui\u6253\u5305exe\u64cd\u4f5c\u6d41\u7a0b\u4ecb\u7ecd"},"content":{"rendered":"<p>nanui\u662f\u4e00\u79cd\u57fa\u4e8ePython\u7684GUI\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u521b\u5efa\u56fe\u5f62\u7528\u6237\u754c\u9762\u3002\u5728Python\u4e2d\uff0c\u6709\u5f88\u591a\u6253\u5305\u5de5\u5177\u53ef\u4ee5\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5176\u4e2d\u6bd4\u8f83\u5e38\u7528\u7684\u6709pyinstaller\u3001cx_Freeze\u548cpy2exe\u7b49\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528pyinstaller\u5c06nanui\u7a0b\u5e8f\u6253\u5305\u6210exe\u6587\u4ef6\u3002<\/p>\n<p>1. \u5b89\u88c5pyinstaller<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5pyinstaller\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>pip install pyinstaller<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u7f16\u5199nanui\u7a0b\u5e8f<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5047\u8bbe\u4f60\u5df2\u7ecf\u719f\u6089nanui\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e76\u4e14\u5df2\u7ecf\u7f16\u5199\u597d\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u7a0b\u5e8f\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684GUI\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b83\u5305\u542b\u4e00\u4e2a\u6309\u94ae\u548c\u4e00\u4e2a\u6807\u7b7e\u3002\u5f53\u7528\u6237\u70b9\u51fb\u6309\u94ae\u65f6\uff0c\u6807\u7b7e\u5c06\u4f1a\u663e\u793a\u201cHello, World!\u201d\u3002<\/p>\n<p>&#8220;`python<\/p>\n<p>import nanui<\/p>\n<p>def on_button_click():<\/p>\n<p>    label.set_text(&#8220;Hello, World!&#8221;)<\/p>\n<p>app = nanui.App(<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/22\/11\/19344700535.jpg\" \/><\/figure>\n<\/p>\n<p>&#8220;My App&#8221;, &#8220;400&#215;300&#8221;)<\/p>\n<p>label = nanui.Label(app, text=&#8221;Welcome to My App!&#8221;)<\/p>\n<p>label.pack()<\/p>\n<p>button = nanui.Button(app, text=&#8221;Click me!&#8221;, command=on_button_click)<\/p>\n<p>button.pack()<\/p>\n<p>app.run()<\/p>\n<p>&#8220;`<\/p>\n<p>3. \u6253\u5305nanui\u7a0b\u5e8f<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u6253\u5305\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>pyinstaller &#8211;on<a href=\"https:\/\/exe.yimenapp.com\/tool-2694.html\">linux\u5730\u56fe\u8f6f\u4ef6<\/a>efile &#8211;windowed app.py<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0c&#8211;onefile\u8868\u793a\u5c06\u6240\u6709\u9700\u8981\u7684\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c&#8211;windowed\u8868\u793a\u4e0d\u663e\u793a\u547d\u4ee4\u884c\u7a97\u53e3\u3002app.py\u662f\u4f60\u7684Python\u7a0b\u5e8f\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<p>4. \u8fd0\u884c\u6253\u5305\u540e\u7684\u7a0b\u5e8f<\/p>\n<p>\u6253\u5305\u5b8c\u6210\u540e\uff0c\u5728dist\u76ee\u5f55\u4e0b\u4f1a\u751f\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u53cc\u51fb\u8be5<a href=\"https:\/\/exe.yimenapp.com\/tool-760.html\">\u505a\u5e94\u7528<\/a>\u6587\u4ef6\u5373\u53ef\u8fd0\u884c\u4f60\u7684nanui\u7a0b\u5e8f\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u4f7f\u7528pyinstaller\u6253\u5305nanui\u7a0b\u5e8f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u51e0\u4e2a\u547d\u4ee4\u5c31\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210exe\u6587\u4ef6\u3002\u5982\u679c\u4f60\u60f3\u8981\u5c06nanui\u7a0b\u5e8f\u5206\u4eab\u7ed9\u5176\u4ed6\u4eba\uff0c\u6253\u5305\u6210exe\u6587\u4ef6\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nanui\u662f\u4e00\u79cd\u57fa\u4e8ePython\u7684GUI\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u521b\u5efa\u56fe\u5f62\u7528\u6237\u754c\u9762\u3002\u5728Python\u4e2d\uff0c\u6709\u5f88\u591a\u6253\u5305\u5de5\u5177\u53ef\u4ee5\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5176\u4e2d\u6bd4\u8f83\u5e38\u7528\u7684\u6709pyinstaller\u3001c<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[13600,19012,1008,132,797],"topic":[],"class_list":["post-11466","post","type-post","status-publish","format-standard","hentry","category-kaifaexe","tag-jfxexe","tag-pkgwindowsexe","tag-1008","tag-132","tag-797"],"_links":{"self":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/11466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/comments?post=11466"}],"version-history":[{"count":0,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/11466\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/media?parent=11466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/categories?post=11466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/tags?post=11466"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/topic?post=11466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}