{"id":2071,"date":"2023-04-01T21:41:42","date_gmt":"2023-04-01T13:41:42","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2071"},"modified":"2023-04-06T16:01:29","modified_gmt":"2023-04-06T08:01:29","slug":"build-python-ui-interface-development-environment","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/build-python-ui-interface-development-environment\/","title":{"rendered":"Python UI\u754c\u9762\u5f00\u53d1\u73af\u5883\u642d\u5efa"},"content":{"rendered":"<h2>\u57fa\u672c\u6b65\u9aa4<\/h2>\n<p>\u901a\u8fc7\u547d\u4ee4\u5206\u522b\u5728cmd\u4e2d\u8fdb\u884c\u5b89\u88c5<\/p>\n<pre><code>pip install PyQt5\n\npip install PyQt5-tools<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff0c\u521b\u5efa\u4e00\u4e2a.py\u6587\u4ef6\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<pre><code class=\"language-python\">import sys\n\nfrom PyQt5 import QtWidgets, QtCore\n\napp = QtWidgets.QApplication(sys.argv)\n\nwidget = QtWidgets.QWidget()\nwidget.resize(360, 360)\nwidget.setWindowTitle(&quot;Hello, PyQt5!&quot;)\nwidget.show()\n\nsys.exit(app.exec_())<\/code><\/pre>\n<p>\u63a5\u7740\u8fdb\u884c\u8fd0\u884c<\/p>\n<h2>\u914d\u7f6ePyCharm<\/h2>\n<p>\u6dfb\u52a0\u4e24\u4e2a\u9009\u9879\u5206\u522b\u662f\uff1a<code>Qt Designer<\/code>\u3001<code>PyUi<\/code><\/p>\n<h3>Qt Designer<\/h3>\n<p>\u9009\u62e9 <code>File<\/code> &#8211; <code>Settings<\/code> &#8211; <code>Tools<\/code> &#8211; <code>External Tools<\/code><\/p>\n<ul>\n<li><code>Name<\/code>\uff1aQt Designer(\u81ea\u5df1\u5b9a\u4e49\uff0c\u559c\u6b22\u5c31\u597d)<\/li>\n<li><code>program<\/code>\uff1aQt Designer\u7684\u5b89\u88c5\u8def\u5f84 \uff08\u4f8b\u5982\uff1aC:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages\\pyqt5_tools\\designer.exe\uff09<\/li>\n<li><code>parameter<\/code>\uff1a\u4e0d\u586b\u00a0<\/li>\n<li><code>directory<\/code>\uff1a<code class=\"mathjax-inline language-mathjax\">FileDir<\/code><\/li>\n<\/ul>\n<h3>PyUi<\/h3>\n<ul>\n<li><code>Name<\/code>\uff1a<code>PyUi<\/code><\/li>\n<li><code>program<\/code>\uff1apyuic\u7684\u5b89\u88c5\u8def\u5f84 (\u4f8b\u5982\uff1aC:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\pyuic5.exe)<\/li>\n<li><code>parameter<\/code>\uff1a<code>$FileName$ -o $FileNameWithoutExtension$.py<\/code><\/li>\n<li><code>directory<\/code>\uff1a<code class=\"mathjax-inline language-mathjax\">FileDir\u00a0<\/code><\/li>\n<\/ul>\n<h2>\u57fa\u4e8ePyCharm\u5f00\u53d1<\/h2>\n<p>\u63a5\u7740\u8fd0\u884c<code>Tools<\/code> &#8211; <code>External Tools<\/code> &#8211; <code>Qt Designer<\/code><\/p>\n<p>\u6253\u5f00QT\u7f16\u8f91\u5668\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u767b\u9646\u754c\u9762\uff0c\u521b\u5efa\u597d\u540e\u4fdd\u5b58\u5230\u9879\u76ee\u76ee\u5f55\u4e0b<\/p>\n<p>\u63a5\u7740\u8fdb\u5165PyCharm\u53f3\u952e\u9009\u62e9\u521a\u624d\u4fdd\u5b58\u7684\u6587\u4ef6\uff08\u540e\u7f00\u4e3a.ui\uff09\uff0c\u9009\u62e9\u53f3\u952e -&gt; <code>External Tools<\/code> -&gt; <code>PyUi<\/code><\/p>\n<p>\u63a5\u7740\u4f1a\u8f6c\u6362\u4e3a\u6269\u5c55\u540d\u4e3a<code>.py<\/code>\u683c\u5f0f\u7684\u6587\u4ef6<\/p>\n<p>\u6253\u5f00\u8f6c\u6362\u540e\u7684<code>.py<\/code>\u6587\u4ef6\uff0c\u5728\u540e\u9762\u52a0\u4e0a<\/p>\n<pre><code class=\"language-python\">if __name__== &quot;__main__&quot;:\n\napp=QtWidgets.QApplication(sys.argv)\n\nwidget=QtWidgets.QWidget()\n\nui=Ui_Dialog()\nui.setupUi(widget)\n\nwidget.show()\n\nsys.exit(app.exec_())<\/code><\/pre>\n<p>\u63a5\u7740\u76f4\u63a5\u8fd0\u884c\u8fd0\u884c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u672c\u6b65\u9aa4 \u901a\u8fc7\u547d\u4ee4\u5206\u522b\u5728cmd\u4e2d\u8fdb\u884c\u5b89\u88c5 pip install PyQt5 pip install PyQt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[523],"class_list":["post-2071","post","type-post","status-publish","format-standard","hentry","category-python","tag-qt"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2071"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2071\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}