{"id":79268,"date":"2026-05-09T17:23:04","date_gmt":"2026-05-09T09:23:04","guid":{"rendered":"https:\/\/www.yimenapp.com\/kb-yimen\/?p=79268"},"modified":"2026-05-09T17:23:04","modified_gmt":"2026-05-09T09:23:04","slug":"%e5%a6%82%e4%bd%95%e8%87%aa%e5%b7%b1%e5%86%99%e4%b8%80%e4%b8%aa%e6%9c%ac%e5%9c%b0app%e5%91%a2%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenapp.com\/kb-yimen\/79268\/","title":{"rendered":"\u5982\u4f55\u81ea\u5df1\u5199\u4e00\u4e2a\u672c\u5730app\u5462\uff1f"},"content":{"rendered":"<p>\u8981\u81ea\u5df1\u5199\u4e00\u4e2a\u672c\u5730<span class=\"wpcom_keyword_link\"><a href=\"https:\/\/www.yimenapp.com\" target=\"_blank\" title=\"\u5f00\u53d1app\u4ece\u4e00\u95e8\u5f00\u59cb\">app<\/a><\/span>\uff0c\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u7684\u7f16\u7a0b\u77e5\u8bc6\u548c\u5de5\u5177\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u8bed\u8a00\u548cPyQt\u5e93\u6765\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u672c\u5730app\u3002<\/p>\n<p>1. \u5b89\u88c5Python\u548cPyQt<\/p>\n<p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Python\u548cPyQt\u5e93\u3002Python\u662f\u4e00\u79cd\u6d41\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u53ef\u4ee5\u5728\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002PyQt<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e6%98%af%e4%b8%80%e4%b8%aa\/\" title=\"\u662f\u4e00\u4e2a\" target=\"_blank\">\u662f\u4e00\u4e2a<\/a><\/span>Python\u5e93\uff0c\u7528\u4e8e\u521b\u5efaGUI<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f\/\" title=\"\u5e94\u7528\u7a0b\u5e8f\" target=\"_blank\">\u5e94\u7528\u7a0b\u5e8f<\/a><\/span>\u3002\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4`pip install pyqt5`\u6765\u5b89\u88c5PyQt5\u3002<\/p>\n<p>2. \u8bbe\u8ba1\u5e94\u7528\u7a0b\u5e8f\u754c\u9762<\/p>\n<p>\u5728PyQt\u4e2d\uff0c\u754c\u9762\u8bbe\u8ba1\u53ef\u4ee5\u4f7f\u7528Qt Designer\u5de5\u5177\u8fdb\u884c\u3002Qt Designer\u662f\u4e00\u4e2a\u53ef\u89c6\u5316\u754c\u9762\u8bbe\u8ba1\u5668\uff0c\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f\u7684\u7528\u6237\u754c\u9762\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Qt Designer\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo apt-get install qttools5-dev-tools<\/p>\n<p>&#8220;`<\/p>\n<p>\u6253\u5f00Qt Designer\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a97\u53e3\uff0c\u7136\u540e\u6dfb\u52a0\u6240\u9700\u7684\u63a7\u4ef6\u548c\u5e03\u5c40\u3002\u4fdd\u5b58\u8bbe\u8ba1<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e6%96%87%e4%bb%b6\/\" title=\"\u6587\u4ef6\" target=\"_blank\">\u6587\u4ef6<\/a><\/span>\u4e3a.ui\u6587\u4ef6\u3002<\/p>\n<p>3. \u5c06UI\u6587\u4ef6\u8f6c\u6362\u4e3aPython\u4ee3\u7801<\/p>\n<p>Qt Designer\u751f\u6210\u7684\u662f.ui\u6587\u4ef6\uff0c\u9700\u8981\u5c06\u5176\u8f6c\u6362\u4e3aPython\u4ee3\u7801\u3002\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4`pyuic5 -x [filename].ui -o [filename].py`\u6765\u5c06UI\u6587\u4ef6\u8f6c\u6362\u4e3aPython\u4ee3\u7801\u3002\u8fd9\u4e2a\u547d\u4ee4\u5c06\u751f\u6210\u4e00\u4e2a\u540d\u4e3afilename.py\u7684\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u4e86UI\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u63a7\u4ef6\u548c\u5e03\u5c40\u3002<\/p>\n<p>4. \u7f16\u5199\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801<\/p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e86\u3002\u9996\u5148\uff0c\u9700\u8981\u5bfc\u5165PyQt5\u5e93\u548cUI\u6587\u4ef6\u751f\u6210\u7684Python\u4ee3\u7801\u3002\u7136\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7c7b\uff0c\u5e76\u5728\u5176\u4e2d\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u7684\u903b\u8f91\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u6dfb\u52a0\u6309\u94ae\u70b9\u51fb\u4e8b\u4ef6\u6216\u6587\u672c\u6846\u8f93\u5165\u4e8b\u4ef6\u7684\u5904\u7406\u7a0b\u5e8f\u3002\u6700\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5b9e\u4f8b\uff0c\u5e76\u5c06\u5176\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<p>&#8220;`python<a href=\"https:\/\/www.yimenapp.cn\/fengzhuang-2232.html\">\u628a\u4e2a\u4eba\u7f51\u7ad9\u505a\u6210app<\/a><\/p>\n<p>import sys<\/p>\n<p>from PyQt5.QtWidgets import QApplication, QMainWindow<\/p>\n<p>from [filename] import Ui_MainWindow<\/p>\n<p>class MyApplication(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>  <a href=\"https:\/\/www.yimenapp.cn\/fengzhuang-2497.html\">\u8d27\u8fd0\u7269\u6d41app\u5f00\u53d1\u9700\u6c42\u6846\u67b6<\/a>      super().__init__()<\/p>\n<p>        self.ui = Ui_MainWindow()<\/p>\n<p>        self.ui.setupUi(self)<\/p>\n<p>        self.ui.pushButton.clicked.connect(self.buttonClicked)<\/p>\n<p>    def buttonClicked(self):<\/p>\n<p>        t<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/28\/13\/26849197788.jpg\" \/><\/figure><\/p>\n<p>ext = self.ui.lineEdit.text()<\/p>\n<p>        self.ui.label.setText(text)<\/p>\n<p>if __name__ == &#8216;__main__&#8217;:<\/p>\n<p>    app = QApplication(sys.argv)<\/p>\n<p>    window = MyApplication()<\/p>\n<p>    window.show()<\/p>\n<p>    sys.exit(app.<span class=\"wpcom_keyword_link\"><a href=\"https:\/\/exe.yimenapp.com\" title=\"exe\u5f00\u53d1\u4ece\u4e00\u95e8\u5f00\u59cb\">exe<\/a><\/span>c_())<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3aMyApplication\u7684\u5e94\u7528\u7a0b\u5e8f\u7c7b\uff0c\u5b83\u7ee7\u627f\u81eaQMainWindow\u3002\u5728\u521d\u59cb\u5316\u51fd\u6570\u4e2d\uff0c\u5c06UI\u6587\u4ef6\u751f\u6210\u7684Python\u4ee3\u7801\u52a0\u8f7d\u5230ui\u53d8\u91cf\u4e2d\uff0c\u5e76\u4f7f\u7528setupUi()\u51fd\u6570\u5c06\u5176\u5e94\u7528\u5230\u4e3b\u7a97\u53e3\u4e2d\u3002\u7136\u540e\uff0c\u5c06\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\u8fde\u63a5\u5230buttonClicked()\u51fd\u6570\u4e2d\uff0c\u5728\u8be5\u51fd\u6570\u4e2d\u83b7\u53d6\u6587\u672c\u6846\u4e2d\u7684\u6587\u672c\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u6807\u7b7e\u7684\u6587\u672c\u3002<\/p>\n<p>5. \u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u73b0\u5728\u53ef\u4ee5\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u4e86\u3002\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884cpython [filename].py\u547d\u4ee4\uff0c\u5373\u53ef\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u81ea\u5df1\u7f16\u5199\u672c\u5730app\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u7684\u7f16\u7a0b\u77e5\u8bc6\u548c\u5de5\u5177\u3002\u4f7f\u7528Python\u548cPyQt\u5e93\u53ef\u4ee5\u5feb\u901f\u5730\u521b\u5efa\u672c\u5730app\u3002\u9700\u8981\u8bbe\u8ba1\u5e94\u7528\u7a0b\u5e8f\u7684\u7528\u6237\u754c\u9762\uff0c\u5e76\u5c06UI\u6587\u4ef6\u8f6c\u6362\u4e3aPython\u4ee3\u7801\u3002\u7136\u540e\uff0c\u7f16\u5199\u5e94\u7528\u7a0b\u5e8f\u7684\u903b\u8f91\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5b9e\u4f8b\u3002\u6700\u540e\uff0c\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u81ea\u5df1\u5199\u4e00\u4e2a\u672c\u5730app\uff0c\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u7684\u7f16\u7a0b\u77e5\u8bc6\u548c\u5de5\u5177\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u8bed\u8a00\u548cPyQt\u5e93\u6765\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u672c\u5730app\u30021. \u5b89\u88c5Python\u548cPyQt\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Python\u548cPyQ<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8057],"tags":[51371,29352,2445,2708,1997],"special":[],"attr":[],"class_list":["post-79268","post","type-post","status-publish","format-standard","hentry","category-appkaifa","tag-cocosapp","tag-webappapp","tag-2445","tag-2708","tag-1997","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/79268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/comments?post=79268"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/79268\/revisions"}],"predecessor-version":[{"id":79294,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/79268\/revisions\/79294"}],"wp:attachment":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/media?parent=79268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/categories?post=79268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/tags?post=79268"},{"taxonomy":"special","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/special?post=79268"},{"taxonomy":"attr","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/attr?post=79268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}