{"id":1520,"date":"2023-03-05T04:01:50","date_gmt":"2023-03-04T20:01:50","guid":{"rendered":"http:\/\/175.24.184.226\/?p=1520"},"modified":"2023-04-23T16:47:06","modified_gmt":"2023-04-23T08:47:06","slug":"pyqt5%e7%ae%80%e5%8d%95%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"\/?p=1520","title":{"rendered":"PyQt5-Pycharm\u7b80\u5355\u914d\u7f6e"},"content":{"rendered":"<h2>1.\u6c49\u5316<\/h2>\n<p><strong>\u4e0b\u8f7d\uff1a<\/strong><\/p>\n<pre><code>\u5efa\u8bae3.7\u7248\u672c\u4ee5\u4e0b\u7684python\u7248\u672c\npip install PyQt5==5.13.0 -i https:\/\/pypi.douban.com\/simple\npip install PyQt5-tools==5.13.0.1.5 -i https:\/\/pypi.douban.com\/simple<\/code><\/pre>\n<p>\u5b89\u88c5PyQt5 \u539f\u5e26\u7684 Designer \u56fe\u5f62\u5316\u8bbe\u8ba1\u754c\u9762\u662f\u82f1\u6587\u7684\uff0c\u5bf9\u82f1\u6587\u4e0d\u597d\u4e4b\u4eba\u591a\u6709\u4e0d\u4fbf\u3002\u4f46\u5728\u7f51\u4e0a\u627e\u5230\u7684\u6559\u7a0b\u90fd\u4e0d\u7b26\u5408\u6211\u8fd9\u4e2a\u7248\u672c\u7684\u64cd\u4f5c\u6d41\u7a0b\uff0c\u4f8b\u5982\u627e\u4e0d\u5230\u4e00\u4e9b\u5bf9\u5e94\u6587\u4ef6\u5939\u3002\u4e0d\u8fc7\u6c49\u5316\u5305\u8fd8\u662f\u6709\u7528\u7684\u3002<\/p>\n<p>\u82f1\u6587\u7248\u5982\u4e0b\u56fe<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/20200709094242313.png\" alt=\"img\" \/>  <\/p>\n<p>\u8f6f\u4ef6\u73af\u5883\uff1a<\/p>\n<ul>\n<li>\n<p>pyqt5     \u7248\u672c\uff1a5.13.0 <\/p>\n<\/li>\n<li>\n<p>pyqt5-tools   \u7248\u672c\uff1a5.13.0.1.5<\/p>\n<\/li>\n<\/ul>\n<p>\u6ce8\uff1a\u6211\u6d4b\u8bd5\u4e86  5.13.0 \u4ee5\u4e0a\u7684\u7248\u672c\uff0c\u4f46\u6c49\u5316\u90fd\u5931\u8d25\u4e86\uff0c\u5982\u679c pyqt \u662f\u5b89\u88c5\u4e865.13.0 \u4ee5\u4e0a\u7248\u672c\uff0c\u63a8\u8350\u5378\u8f7d\u4e86\u91cd\u88c5 pyqt5 \u548c pyqt5-tools\u3002<\/p>\n<p><strong>\u6c49\u5316\u5305\u4e0b\u8f7d<\/strong> <\/p>\n<p>\u94fe\u63a5\uff1a<a href=\"https:\/\/pan.baidu.com\/s\/10_08RpfOqhMD0zSVwBnmVQ\">https:\/\/pan.baidu.com\/s\/10_08RpfOqhMD0zSVwBnmVQ<\/a><br \/>\n\u63d0\u53d6\u7801\uff1afadx <\/p>\n<p>\u4e0b\u8f7d\uff08\u89e3\u538b\uff09\u5f97\u5230designer_zh_CN.qm\u6587\u4ef6\uff0c\u653e\u5728\u4e0b\u9762\u7684\u6587\u4ef6\u5939\u4e2d<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305032511186.png\" alt=\"image-20230305032511186\" \/><\/p>\n<p><strong>\u53c2\u8003\u94fe\u63a5<\/strong><\/p>\n<p><a href=\"https:\/\/blog.csdn.net\/qq_38463737\/article\/details\/107221910\">https:\/\/blog.csdn.net\/qq_38463737\/article\/details\/107221910<\/a><\/p>\n<h2>2.pycharm\u914d\u7f6e<\/h2>\n<p>pyqt5 \u4e3b\u8981\u5305\u62ec\u4e0b\u9762\u7684\u4e09\u4e2a\u5de5\u5177\u914d\u7f6e\uff1a<\/p>\n<p>\u30101\u3011QtDesigner\u7684\u914d\u7f6e\uff1a\u76ee\u7684\u662f\u5728PyCharm\u5f00\u53d1\u73af\u5883\u4e2d\u5feb\u901f\u6253\u5f00\u8bbe\u8ba1\u754c\u9762<\/p>\n<p>\u30102\u3011Pyuic5\u7684\u914d\u7f6e\uff1a\u76ee\u7684\u662f\u5c06Qt Designer\u8bbe\u8ba1\u7684\u201c.ui\u201d\u754c\u9762\u6587\u4ef6\u8f6c\u6362\u6210\u201c.py\u201d\u6587\u4ef6<\/p>\n<p>\u30103\u3011Pyrcc5\u7684\u914d\u7f6e\uff1a\u76ee\u7684\u662f\u5c06Qt Designer\u8bbe\u8ba1\u4e2d\u7528\u5230\u7684\u8d44\u6e90\u6587\u4ef6\u201c.qrc\u201d\u8f6c\u6362\u6210\u201c.py\u201d\u6587\u4ef6<\/p>\n<h3>2.1 QtDesigner\u914d\u7f6e<\/h3>\n<p>\u70b9\u51fb\u52a0\u53f7\u540e\u5f39\u51fa\u6dfb\u52a0\u754c\u9762\uff0c\u8981\u6ce8\u610f\u7684\u8bbe\u7f6e\u53c2\u6570\u5982\u4e0b<\/p>\n<p>Group:PyQt5\uff08\u8fd9\u4e2a\u662f\u4e3a\u4e86\u65b9\u4fbf\u7ba1\u7406\u6269\u5c55\u5de5\u5177\uff0c\u628a\u4e0ePyQt5\u76f8\u5173\u7684\u63d2\u4ef6\u90fd\u653e\u5728\u8fd9\u4e2a\u7ec4\u91cc\uff0c\u540e\u9762\u4e24\u4e2a\u4e5f\u662f\uff09<\/p>\n<p>program\uff1aC:\\Program Files\\python37\\Scripts\\designer.exe,\uff08\u8fd9\u4e2a\u662f\u6211designer.exe\u5b89\u88c5\u7684\u5730\u5740\uff0c\u8981\u6362\u6210\u4f60\u81ea\u5df1\u7684designer.exe\u5730\u5740\uff09<br \/>\narguments\uff1a$FileDir$\\$FileName$ <\/p>\n<p>working directory\uff1a$FileDir$<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305034612569.png\" alt=\"image-20230305034612569\" \/><\/p>\n<h3>2.2Pyuic5\u7684\u914d\u7f6e<\/h3>\n<p>\u518d\u70b9\u51fb\u52a0\u53f7+ \u8fdb\u884c\u8bbe\u7f6e\u6dfb\u52a0Pyuic5\uff0c  \u8981\u6ce8\u610f\u7684\u8bbe\u7f6e\u53c2\u6570\u5982\u4e0b<\/p>\n<p>program\uff1aC:\\Program Files\\python37\\Scripts\\pyuic5.exe,\uff08\u8fd9\u4e2a\u662f\u6211pyuic5.exe\u5b89\u88c5\u7684\u5730\u5740\uff0c\u8981\u6362\u6210\u4f60\u81ea\u5df1\u7684pyuic5.exe\u5730\u5740\uff09<br \/>\narguments\uff1a$FileName$ -o $FileNameWithoutExtension$.py<\/p>\n<p>working directory\uff1a$FileDir$<\/p>\n<p>\u8bbe\u7f6e\u5b8c\u70b9\u51fbOK<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305034849490.png\" alt=\"image-20230305034849490\" \/> <\/p>\n<h3>2.3Pyrcc5\u7684\u914d\u7f6e<\/h3>\n<p>program\uff1aC:\\Program Files\\python37\\Scripts\\pyrcc5.exe,\uff08\u8fd9\u4e2a\u662f\u6211pyrcc5.exe\u5b89\u88c5\u7684\u5730\u5740\uff0c\u8981\u6362\u6210\u4f60\u81ea\u5df1\u7684pyrcc5.exe\u5730\u5740\uff09<br \/>\narguments\uff1a$FileName$ -o $FileNameWithoutExtension$.py<\/p>\n<p>working directory\uff1a$FileDir$<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035007558.png\" alt=\"image-20230305035007558\" \/> <\/p>\n<h2>3.\u9a8c\u8bc1<\/h2>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035125540.png\" alt=\"image-20230305035125540\" \/> <\/p>\n<p>\u5728\u8fd9\u4e2a\u754c\u9762\u9009\u62e9Main Window\uff0c\u70b9\u51fbCreate<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035621238.png\" alt=\"image-20230305035621238\" style=\"zoom:50%;\" \/> <\/p>\n<p>\u627e\u5230Text Browser\u63a7\u4ef6\uff0c\u628a\u4ed6\u62d6\u5230\u8bbe\u8ba1\u7a97\u53e3<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035643219.png\" alt=\"image-20230305035643219\" \/> <\/p>\n<p>\u53cc\u51fb\u521a\u62d6\u51fa\u7684\u6587\u672c\u63a7\u4ef6\uff0c\u8f93\u5165Hello World!<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035659731.png\" alt=\"image-20230305035659731\" \/><\/p>\n<p>\u70b9\u51fb\u4fdd\u5b58UI\u6587\u4ef6<\/p>\n<p><strong><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035713339.png\" alt=\"image-20230305035713339\" \/><\/strong><\/p>\n<p>\u30102\u3011\u5355\u5355\u6709UI\u6587\u4ef6\u662f\u4e0d\u884c\u7684\u6211\u4eec\u8fd8\u9700\u8981\u628a\u4ed6\u8f6c\u6362\u4e3apy\u6587\u4ef6\uff0c\u8fd9\u5c31\u8981\u7528\u7684pyuic5 \u5de5\u5177\u4e86\u3002<\/p>\n<p>\u53f3\u51fbuntitled.ui\u6587\u4ef6\uff0c\u5982\u56fe\u9009\u62e9\u70b9\u51fbpyuic5<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035744144.png\" alt=\"image-20230305035744144\" \/><\/p>\n<p>\u5982\u4e0b\u56fe\u51fa\u73b0untitled.py\u6587\u4ef6\u8bf4\u660epyuic5\u5b89\u88c5\u8bbe\u7f6e\u662f\u6210\u529f\u7684<\/p>\n<p><strong><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035759747.png\" alt=\"image-20230305035759747\" \/><\/strong><\/p>\n<p>\u30103\u3011\u6709\u4e86UI\u7684py\u6587\u4ef6\u6211\u4eec\u8fd8\u662f\u8fd0\u884c\u4e0d\u51fa\u754c\u9762\u7684\uff0c\u6211\u4eec\u8fd8\u6dfb\u52a0\u4e00\u4e2apy\u6587\u4ef6\u6765\u8c03\u7528uipy\u6587\u4ef6\u5e76\u5177\u4f53\u5316ui\u7c7b\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a.py\u7a0b\u5e8f\u6587\u4ef6\uff1a\u53f3\u51fbu2 D\\code python\\u2\u4f4d\u7f6e\uff0c\u6700\u540e\u70b9\u51fbPython File<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035833351.png\" alt=\"image-20230305035833351\" \/><\/p>\n<p>\u7136\u540e\u547d\u540d\u5b8c \u56de\u8f66\u5373\u53ef<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035846637.png\" alt=\"image-20230305035846637\" \/><\/p>\n<p>\u5728test.py\u6587\u4ef6\u8f93\u5165\u5982\u4e0b\u4ee3\u7801\u5e76\u8fd0\u884c<\/p>\n<pre><code class=\"language-python\">import sys\nimport PyQt5\nimport untitled  #\u521a\u521a\u8f6c\u4e3apy\u6587\u4ef6\u7684UI\u6587\u4ef6\u540d\uff0c\u6211\u7684\u662funtitled\nfrom PyQt5.QtWidgets import QApplication, QMainWindow\n\nif __name__ == &#039;__main__&#039;:\n    app = QApplication(sys.argv)\n    MainWindow = QMainWindow()\n    ui = untitled.Ui_MainWindow()\n    ui.setupUi(MainWindow)\n    MainWindow.show()\n    sys.exit(app.exec_())<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230305035916388.png\" alt=\"image-20230305035916388\" \/><\/p>\n<p>\u5f39\u51fa\u6765\u7ea2\u6846\u7684\u754c\u9762\uff0c\u8bf4\u660e\u4f60PyQt5\u5b89\u88c5\u8c03\u8bd5\u5df2\u7ecf\u5b8c\u6210\uff0c\u53ef\u4ee5\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684PyQt5\u5b66\u4e60\u4e86\u3002<\/p>\n<p>\u52a0\u6cb9\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u6c49\u5316 \u4e0b\u8f7d\uff1a \u5efa\u8bae3.7\u7248\u672c\u4ee5\u4e0b\u7684python\u7248\u672c pip install PyQt5==5.13.0 -i https:\/\/pyp   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[132],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1520"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1520"}],"version-history":[{"count":3,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1520\/revisions"}],"predecessor-version":[{"id":1806,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1520\/revisions\/1806"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1520"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}