{"id":8774,"date":"2023-09-11T12:18:47","date_gmt":"2023-09-11T04:18:47","guid":{"rendered":"https:\/\/app.60day.cn\/appday\/?p=8774"},"modified":"2023-09-11T12:18:47","modified_gmt":"2023-09-11T04:18:47","slug":"gui%e8%b0%83%e7%94%a8%e5%a4%96%e9%83%a8%e7%a8%8b%e5%ba%8f%e7%94%9f%e6%88%90exe%e8%a6%81%e6%80%8e%e4%b9%88%e5%81%9a%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/app.60day.cn\/appday\/kaifaexe\/8774\/","title":{"rendered":"gui\u8c03\u7528\u5916\u90e8\u7a0b\u5e8f\u751f\u6210exe\u8981\u600e\u4e48\u505a\uff1f"},"content":{"rendered":"<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u4f7f\u7528GUI\uff08\u56fe\u5f62\u7528\u6237\u754c\u9762\uff09\u8c03\u7528\u5916\u90e8\u7a0b\u5e8f\u4ee5\u751f\u6210\u4e00\u4e2aEXE\u6587\u4ef6\u3002\u672c\u6559\u7a0b\u5c06\u6309\u4ee5\u4e0b\u987a\u5e8f\u8fdb\u884c\uff1a\u539f\u7406\u4ecb\u7ecd\u3001\u51c6\u5907\u5de5\u4f5c\u3001\u5b9e\u9645\u64cd\u4f5c\u548c\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n<p>**\u539f\u7406\u4ecb\u7ecd**<\/p>\n<p>\u751f\u6210EXE\u6587\u4ef6\u7684\u65b9\u5f0f\u591a\u79cd\u591a\u6837\uff0c\u4f8b\u5982\u4f7f\u7528\u7f16\u8bd1\u5668\u7f16\u8bd1\u6e90\u4ee3\u7801\uff08\u5982C\u3001C++\u3001C#\u548cVB\u7b49\u7f16\u7a0b\u8bed\u8a00\uff09\u6216\u4f7f\u7528\u811a\u672c\u8f6c\u6362\u5de5\u5177\uff08\u5982PyInstaller\u5728Python\u4e2d\uff09\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528GUI\u6765\u8c03\u7528\u7f16\u8bd1\u5668\u6216\u5176\u4ed6\u5de5\u5177\uff0c\u4ee5\u751f\u6210\u6211\u4eec\u9700\u8981\u7684EXE\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>**\u51c6\u5907\u5de5\u4f5c**<\/p>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807\uff0c\u8bf7\u786e\u4fdd\u5df2\u6b63\u786e\u5b89\u88c5\u4ee5\u4e0b\u7a0b\u5e8f\u6216\u5e93\uff1a<\/p>\n<p>1. \u9488\u5bf9\u6240\u9700\u7f16\u7a0b\u8bed\u8a00\u6216\u6280\u672f\u5b89\u88c5\u76f8\u5e94\u7684\u7f16\u8bd1\u5668\u6216\u5de5\u5177\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>   &#8211; \u5bf9\u4e8eC \/ C++: \u5b89\u88c5GCC\u6216Visual Studio<\/p>\n<p>   &#8211; \u5bf9\u4e8ePython: \u5b89\u88c5Python\u53caPyInstaller\u5e93\u3002<\/p>\n<p>2. \u5f00\u53d1GUI\u7684\u5de5\u5177\uff0c \u5982\uff1aPyQt5\u3001tkinter\u7b49\u3002<\/p>\n<p>**\u5b9e\u9645\u64cd\u4f5c**<\/p>\n<p>\u4ee5\u4e0b\u662f\u5b9e\u73b0\u7684\u57fa\u672c\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u521b\u5efa\u4e00\u4e2aGUI\u7a0b\u5e8f\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u6309\u94ae\u548c\u4e00\u4e2a\u6587\u672c\u6846\u3002<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/20\/11\/20762987684.jpg\" \/><\/figure>\n<\/p>\n<p>\u6309\u94ae\u7528\u4e8e\u89e6\u53d1\u7f16\u8bd1\u8fc7\u7a0b\uff0c\u6587\u672c\u6846\u663e\u793a\u7f16\u8bd1\u8fc7\u7a0b\u7684\u8f93\u51fa\u4fe1\u606f\u3002<\/p>\n<p>2. \u5f53\u6309\u94ae\u88ab\u5355\u51fb\u65f6\uff0c\u4eceGUI\u7a0b\u5e8f\u4e2d\u8c03\u7528\u7f16\u8bd1\u5668\u6216\u5176\u4ed6\u5de5\u5177\u751f\u6210EXE\u6587\u4ef6\u3002<\/p>\n<p>3. \u5c06\u7f16\u8bd1\u5de5\u5177\u7684\u8f93\u51fa\u91cd\u5b9a\u5411\u5e76\u663e\u793a\u5728GUI\u5e94\u7528\u7a0b\u5e8f\u7684\u6587\u672c\u6846\u4e2d\uff08\u53ef\u9009\uff09\u3002<\/p>\n<p>**\u793a\u4f8b\u4ee3\u7801**<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u57fa\u4e8ePython\u548cPyInstaller\u7684\u7b80\u5355\u793a\u4f8b\u3002\u6211\u4eec\u5c06\u4f7f\u7528Python\u7684tkinter\u5e93\u6765\u521b\u5efaGUI\uff1a<\/p>\n<p>&#8220;`python<\/p>\n<p>import tkinter as tk<\/p>\n<p>import subprocess<\/p>\n<p>def compile_exe():<\/p>\n<p>    pyinstaller_path = &#8220;pyinstaller&#8221;  # \u6216\u8f93\u5165\u4f60\u7684PyInstaller\u5b8c\u6574\u8def\u5f84<\/p>\n<p>    source_file = &#8220;your_script.py&#8221;  # \u8981\u7f16\u8bd1\u7684Python\u811a\u672c\u540d<\/p>\n<\/p>\n<p>    command = f&#8221;{pyinstaller_path} &#8211;onefile {source_file}&#8221;<\/p>\n<\/p>\n<p>    process = subprocess.Popen(<\/p>\n<p>        command,<\/p>\n<p>        shell=True,<\/p>\n<p>        stdout=subprocess.PIPE,<\/p>\n<p>        stderr=subprocess.PIPE,<\/p>\n<p>        text=True<\/p>\n<p>    )<\/p>\n<\/p>\n<p>    output, errors = process.communicate()<\/p>\n<\/p>\n<p>    output_text.delete(1.0, tk.END)<\/p>\n<p>    output_text.insert(tk.END, output)<\/p>\n<p>    if errors:<\/p>\n<p>        output_text.insert(tk.END, &#8220;\\n\\nERRORS:\\n&#8221;)<\/p>\n<p>        output_text.insert(tk.END, errors)<\/p>\n<p>app = tk.Tk()<\/p>\n<p>app.title(&#8220;Exe Generator GUI&#8221;)<\/p>\n<p>app.geometry(&#8220;600&#215;400&#8221;)<\/p>\n<p>compile_button = tk.Button(app, text=&#8221;Compile&#8221;, command=compile_exe)<\/p>\n<p>compile_button.pack(padx=10, pady=10)<\/p>\n<p>output_text = tk.Text(app, wrap=tk.WORD)<\/p>\n<p>output_text.pack<a href=\"https:\/\/exe.yimenapp.com\/tool-3647.html\">\u8de8\u5e73\u53f0\u684c\u9762\u5e94\u7528<\/a>(expand=True, fill=tk.BOTH)<\/p>\n<p>app.mainloop()<\/p>\n<p>&#8220;`<\/p>\n<p>\u6ce8\u610f\uff1a\u8bf7\u786e\u4fdd\u5728\u8fd0\u884c\u6b64\u793a\u4f8b\u4ee3\u7801\u4e4b\u524d\u5b89\u88c5\u4e86Python\u3001PyInstaller\u5e93\u4ee5\u53ca\u6e90\u6587\u4ef6\u8def\u5f84\u5df2\u6b63\u786e\u586b\u5199\u3002<\/p>\n<p>\u603b\u7ed3\uff1a\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u901a\u8fc7GUI\u8c03\u7528\u5916\u90e8\u7a0b<a href=\"https:\/\/www.yimenexe.com\/ruanjian-kaifa-734.html\">java\u9879\u76ee\u5982\u4f55\u751f\u6210exe\u6587\u4ef6<\/a>\u5e8f\u4ee5\u751f\u6210EXE\u5e94\u7528\u7a0b\u5e8f\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u4f60\u6240\u9700\u8981\u7684\u7f16\u7a0b\u8bed\u8a00\u548cGUI\u5e93\u8fdb\u884c\u76f8\u5e94\u7684\u8c03\u6574\u3002\u5982\u679c\u4f60\u9075\u5faa\u672c\u6559\u7a0b\u7684\u6b65\u9aa4, \u8fd8\u53ef\u4ee5\u81ea\u5b9a\u4e49\u4f60\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762, \u4ee5\u6ee1\u8db3\u4e0d\u540c\u9700\u6c42\u7684\u7f16\u8bd1\u4efb\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u4f7f\u7528GUI\uff08\u56fe\u5f62\u7528\u6237\u754c\u9762\uff09\u8c03\u7528\u5916\u90e8\u7a0b\u5e8f\u4ee5\u751f\u6210\u4e00\u4e2aEXE\u6587\u4ef6\u3002\u672c\u6559\u7a0b\u5c06\u6309\u4ee5\u4e0b\u987a\u5e8f\u8fdb\u884c\uff1a\u539f\u7406\u4ecb\u7ecd\u3001\u51c6\u5907\u5de5\u4f5c\u3001\u5b9e\u9645\u64cd\u4f5c\u548c\u793a\u4f8b\u4ee3\u7801\u3002**\u539f\u7406\u4ecb\u7ecd**\u751f\u6210EXE\u6587\u4ef6\u7684\u65b9\u5f0f\u591a\u79cd\u591a\u6837<\/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":[15355,15354,24,5709,1241],"topic":[],"class_list":["post-8774","post","type-post","status-publish","format-standard","hentry","category-kaifaexe","tag-exe","tag-javaexe","tag-24","tag-5709","tag-1241"],"_links":{"self":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/8774","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=8774"}],"version-history":[{"count":0,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/8774\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/media?parent=8774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/categories?post=8774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/tags?post=8774"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/topic?post=8774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}