{"id":1331,"date":"2023-06-27T12:19:22","date_gmt":"2023-06-27T04:19:22","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/2023\/ruanjiankf\/1331\/"},"modified":"2023-06-27T12:19:22","modified_gmt":"2023-06-27T04:19:22","slug":"gui%e6%89%93%e5%8c%85exe%e7%9a%84%e5%8e%9f%e7%90%86%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2023\/ruanjiankf\/1331\/","title":{"rendered":"gui\u6253\u5305exe\u7684\u539f\u7406\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p>GUI\u6253\u5305EXE\u8be6\u7ec6\u4ecb\u7ecd:<\/p>\n<p>\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u53ef\u4ee5\u63d0\u9ad8\u7528\u6237\u4e0e\u7a0b\u5e8f\u4ea4\u4e92\u7684\u53cb\u597d\u7a0b\u5ea6\u3002\u800c\u5c06\u5305\u542bGUI\u7684\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\u975e\u5e38\u91cd\u8981\u3002\u8fd9\u4f7f\u5f97\u7528\u6237\u65e0\u9700\u5b89\u88c5\u4efb\u4f55\u4f9d\u8d56\u9879\uff0c\u5373\u53ef\u65b9\u4fbf\u5730\u5728\u5404\u79cd\u5e73\u53f0\u4e0a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u4ecb\u7ecdGUI\u6253\u5305EXE\u7684\u539f\u7406\u4ee5\u53ca\u8be6\u7ec6\u8fc7\u7a0b\u3002<\/p>\n<p>### \u539f\u7406\uff1a<\/p>\n<p>GUI\u6253\u5305EXE\u7ecf\u5386\u4e86\u5982\u4e0b\u4e09\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u9996\u5148\uff0c\u7f16\u5199\u4e00\u4e2a\u5305\u542b\u56fe\u5f62\u754c\u9762\u7684\u7a0b\u5e8f\uff0c\u901a\u5e38\u91c7\u7528Python\u3001C#\u3001Java\u7b49\u7f16\u7a0b\u8bed\u8a00\u3002<\/p>\n<p>2. \u5176\u6b21\uff0c\u4f7f\u7528\u76f8\u5e94\u7684\u5de5\u5177\uff08\u5982PyInstaller\u3001NSIS\u3001Inno Setup\u7b49\uff09\u5c06\u7a0b\u5e8f\u53ca\u5176\u4f9d\u8d56\u5e93\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd9\u4e2a\u5de5\u5177\u4f1a\u4e3a\u7a0b\u5e8f\u521b\u5efa\u4e00\u4e2a\u201c\u58f3\u201d\uff0c\u5e76\u5c06<a href=\"https:\/\/exe.yimenapp.com\/tool-1215.html\">h5\u8f6cexe<\/a>\u7a0b\u5e8f\u7684\u6240\u6709\u5185\u5bb9\u548c\u4f9d\u8d56\u5e93\uff08\u5982\u52a8\u6001\u94fe\u63a5\u5e93\u3001Python\u8fd0\u884c\u65f6\u5e93\u7b49\uff09\u6253\u5305\u5230\u8fd9\u4e2a\u201c\u58f3\u201d\u4e2d\u3002<\/p>\n<p>3. \u6700\u540e\uff0c\u7528\u6237\u5728\u8fd0\u884c\u8be5EXE\u6587\u4ef6\u65f6\uff0c\u58f3\u7a0b\u5e8f\u9996\u5148\u89e3\u538b\u5185\u90e8\u7684\u4f9d\u8d56\u5e93\u548c\u7a0b\u5e8f\u672c\u8eab\u5230\u4e34\u65f6\u6587\u4ef6\u5939\uff0c\u7136\u540e\u6267\u884c\u7a0b\u5e8f\u7684\u5165\u53e3\u3002<\/p>\n<p>### \u8be6\u7ec6\u8fc7\u7a0b\uff1a<\/p>\n<p>\u4ee5\u5c06\u4e00\u4e2aPython\u7684GUI\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210EXE\u6587\u4ef6\u4e3a\u4f8b\uff0c\u8be6\u7ec6\u4ecb\u7ecd\u6253\u5305\u8fc7\u7a0b\uff1a<\/p>\n<p>1. \u7f16\u5199\u4e00\u4e2a\u5305\u542b\u56fe\u5f62\u754c\u9762\u7684Python\u7a0b\u5e8f\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5Tkinter\u5e93\u4e3a\u4f8b\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>&#8220;`python<\/p>\n<p># \u6587\u4ef6\u540d: gui_app.py<\/p>\n<p>import tkinter as tk<\/p>\n<p>def on_click():<\/p>\n<p>    label.config(text=&#8221;Hello &#8221; + entry.get())<\/p>\n<p>app = tk.Tk()<\/p>\n<p>app.title(&#8220;My GUI App&#8221;)<\/p>\n<p>frame = tk.Frame(app)<\/p>\n<p>frame.pack(padx=10, pady=10)<\/p>\n<p>entry = tk.Entry(frame)<\/p>\n<p>entry.pack(padx=5, pady=5)<\/p>\n<p>button = tk.Button(frame, text=&#8221;Greet&#8221;, com<\/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>mand=on_click)<\/p>\n<p>button.pack(padx=5, pady=5)<\/p>\n<p>label = tk.Label(frame, text=&#8221;<a href=\"https:\/\/www.yimenexe.com\/ruanjian-kaifa-5456.html\">\u5c01\u88c5\u7684exe\u811a\u672c<\/a>Welcome!&#8221;)<\/p>\n<p>label.pack(padx=5, pady=5)<\/p>\n<p>app.mainloop()<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u5b89\u88c5\u4e00\u4e2a\u7528\u4e8e\u6253\u5305Python\u7a0b\u5e8f\u7684\u5de5\u5177\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5PyInstaller\u4e3a\u4f8b\uff1a<\/p>\n<p>&#8220;`shell<\/p>\n<p>pip install pyinstaller<\/p>\n<p>&#8220;`<\/p>\n<p>3. \u4f7f\u7528PyInstaller\u5c06python\u7a0b\u5e8f\u6253\u5305\u4e3aEXE\u6587\u4ef6\uff1a<\/p>\n<p>&#8220;`shell<\/p>\n<p>pyinstaller &#8211;onefile &#8211;noconsole gui_app.py<\/p>\n<p>&#8220;`<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>&#8211; &#8211;onefile\uff1a\u8868\u793a\u5c06\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684EXE\u6587\u4ef6\u3002<\/p>\n<p>&#8211; &#8211;noconsole\uff1a\u8868\u793a\u8fd0\u884c\u7a0b\u5e8f\u65f6\u4e0d\u663e\u793a\u63a7\u5236\u53f0\u7a97\u53e3\u3002<\/p>\n<p>4. \u8fdb\u5165`dist`\u76ee\u5f55\uff0c\u627e\u5230`gui_app.exe`\u6587\u4ef6\uff0c\u53cc\u51fb\u5373\u53ef\u8fd0\u884c\u5305\u542bGUI\u7684\u7a0b\u5e8f\u3002<\/p>\n<p>\u6ce8\u610f\uff1aPyInstaller\u6253\u5305\u540e\u7684EXE\u6587\u4ef6\u5728\u5f53\u524d\u7cfb\u7edf\u4e2d\u5e94\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u4f46\u4e3a\u4e86\u786e\u4fdd\u517c\u5bb9\u6027\uff0c\u5728\u4e0d\u540c\u7cfb\u7edf\u4e0a\u7684\u8fd0\u884c\uff0c\u8bf7\u52a1\u5fc5\u5728\u76ee\u6807\u7cfb\u7edf\u4e0a\u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5c06\u4e00\u4e2aGUI\u7a0b\u5e8f\u6253\u5305\u6210EXE\u6587\u4ef6\u7684\u539f\u7406\u548c\u8be6\u7ec6\u8fc7\u7a0b\u3002\u8bf7\u52a1\u5fc5\u6ce8\u610f\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u60a8\u9879\u76ee\u7684\u6253\u5305\u5de5\u5177\uff0c\u5e76\u6309\u7167\u5b98\u65b9\u6307\u5357\u6765\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u80fd\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883\u4e2d\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GUI\u6253\u5305EXE\u8be6\u7ec6\u4ecb\u7ecd:\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u53ef\u4ee5\u63d0\u9ad8\u7528\u6237\u4e0e\u7a0b\u5e8f\u4ea4\u4e92\u7684\u53cb\u597d\u7a0b\u5ea6\u3002\u800c\u5c06\u5305\u542bGUI\u7684\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\u975e\u5e38\u91cd\u8981\u3002\u8fd9\u4f7f\u5f97\u7528\u6237\u65e0\u9700\u5b89\u88c5\u4efb\u4f55\u4f9d\u8d56\u9879\uff0c\u5373\u53ef\u65b9\u4fbf\u5730\u5728<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2879,1305,81,179,2878],"topic":[],"class_list":["post-1331","post","type-post","status-publish","format-standard","hentry","category-ruanjiankf","tag-2879","tag-exe","tag-81","tag-179"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/1331","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\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=1331"}],"version-history":[{"count":0,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/1331\/revisions"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=1331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=1331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=1331"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=1331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}