{"id":15410,"date":"2024-12-13T15:14:29","date_gmt":"2024-12-13T07:14:29","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=15410"},"modified":"2024-12-13T15:14:29","modified_gmt":"2024-12-13T07:14:29","slug":"agentclientdemo","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/ja\/agentclientdemo\/","title":{"rendered":"AgentClientDemo\uff1a\u6f14\u793a\u667a\u80fd\u4f53\u8fd0\u884c\u8fc7\u7a0b\u7684Python\u5ba2\u6237\u7aef\uff0c\u63d0\u4f9b\u76f4\u89c2\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762"},"content":{"rendered":"<p>AgentClientDemo \u662f\u4e00\u4e2a\u96c6\u6210\u4e86\u667a\u80fd\u4f53\uff08Agent\uff09\u548c\u5ba2\u6237\u7aef\uff08Client\uff09\u529f\u80fd\u7684\u7efc\u5408\u6027 Python \u9879\u76ee\u3002\u8be5\u9879\u76ee\u57fa\u4e8e PyQt \u6846\u67b6\u5f00\u53d1\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u76f4\u89c2\u6613\u7528\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u3002\u901a\u8fc7\u672c\u9879\u76ee\uff0c\u7528\u6237\u53ef\u4ee5\u4f53\u9a8c\u5230\u667a\u80fd\u4f53\u7684\u5f3a\u5927\u529f\u80fd\uff0c\u540c\u65f6\u4eab\u53d7 PyQt \u5e26\u6765\u7684\u9ad8\u6548\u5f00\u53d1\u4f53\u9a8c\u3002\u9879\u76ee\u7ed3\u6784\u6e05\u6670\uff0c\u5305\u542b\u667a\u80fd\u4f53\u6838\u5fc3\u903b\u8f91\u3001\u5de5\u5177\u5e93\u3001\u6a21\u578b\u4ee5\u53ca\u5ba2\u6237\u7aef\u754c\u9762\u8bbe\u8ba1\u6587\u4ef6\u7b49\u6a21\u5757\uff0c\u9002\u5408\u5f00\u53d1\u8005\u5feb\u901f\u4e0a\u624b\u5e76\u8fdb\u884c\u4e8c\u6b21\u5f00\u53d1\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li>\u63d0\u4f9b\u667a\u80fd\u4f53\uff08Agent\uff09\u529f\u80fd\uff0c\u80fd\u591f\u81ea\u4e3b\u601d\u8003\u548c\u6267\u884c\u7528\u6237\u6307\u4ee4<\/li>\n<li>\u57fa\u4e8e PyQt \u6846\u67b6\u5f00\u53d1\uff0c\u63d0\u4f9b\u76f4\u89c2\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09<\/li>\n<li>\u652f\u6301\u591a\u79cd\u5de5\u5177\u548c\u8d44\u6e90\u7684\u8c03\u7528\uff0c\u589e\u5f3a\u667a\u80fd\u4f53\u80fd\u529b<\/li>\n<li>\u5305\u542b\u8be6\u7ec6\u7684\u9879\u76ee\u7ed3\u6784\u548c\u4ee3\u7801\u6587\u4ef6\uff0c\u4fbf\u4e8e\u5f00\u53d1\u8005\u7406\u89e3\u548c\u4f7f\u7528<\/li>\n<li>\u63d0\u4f9b\u754c\u9762\u8bbe\u8ba1\u6587\u4ef6\u548c\u8f6c\u6362\u811a\u672c\uff0c\u65b9\u4fbf\u7528\u6237\u81ea\u5b9a\u4e49\u754c\u9762<\/li>\n<li>\u652f\u6301 Python \u8bed\u8a00\uff0c\u5229\u7528\u5176\u4e30\u5bcc\u7684\u5e93\u548c\u6846\u67b6\u8fdb\u884c\u5f00\u53d1<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<ol>\n<li>\u786e\u4fdd\u5df2\u5b89\u88c5 Python \u73af\u5883\uff0c\u53ef\u4ee5\u4ece Python \u5b98\u7f51 \u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002<\/li>\n<li>\u4f7f\u7528 pip \u5b89\u88c5 PyQt \u5e93\uff1a<\/li>\n<\/ol>\n<pre><code>   pip install PyQt5\r\n<\/code><\/pre>\n<p>\u5982\u679c\u60f3\u4f7f\u7528 PyQt6\uff0c\u8bf7\u5c06\u4e0a\u8ff0\u547d\u4ee4\u4e2d\u7684\u201c5\u201d\u66ff\u6362\u4e3a\u201c6\u201d\u3002<\/p>\n<ol start=\"3\">\n<li>\u514b\u9686\u9879\u76ee\u4ee3\u7801\u5230\u672c\u5730\uff1a<\/li>\n<\/ol>\n<pre><code>   git clone https:\/\/github.com\/MrLi008\/AgentClientDemo.git\r\n<\/code><\/pre>\n<ol start=\"4\">\n<li>\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\u5e76\u5b89\u88c5\u4f9d\u8d56\u5e93\uff1a<\/li>\n<\/ol>\n<pre><code>   cd AgentClientDemo\r\npip install -r requirements.txt\r\n<\/code><\/pre>\n<h3>\u4f7f\u7528\u6307\u5357<\/h3>\n<ol>\n<li>\u8fd0\u884c\u4e3b\u7a0b\u5e8f\u5165\u53e3\u6587\u4ef6 <code>main.py<\/code>\uff1a<\/li>\n<\/ol>\n<pre><code>   python main.py\r\n<\/code><\/pre>\n<ol start=\"2\">\n<li>\u6253\u5f00\u5e94\u7528\u7a0b\u5e8f\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u76f4\u89c2\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u754c\u9762\u4e0e\u667a\u80fd\u4f53\u8fdb\u884c\u4ea4\u4e92\u3002<\/li>\n<li>\u5728\u754c\u9762\u4e2d\uff0c\u53ef\u4ee5\u8f93\u5165\u6307\u4ee4\u6216\u4efb\u52a1\uff0c\u667a\u80fd\u4f53\u4f1a\u6839\u636e\u6307\u4ee4\u8c03\u7528\u76f8\u5e94\u7684\u5de5\u5177\u6216\u8d44\u6e90\u6765\u5b8c\u6210\u4efb\u52a1\u3002<\/li>\n<li>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u754c\u9762\u4e0a\u7684\u6309\u94ae\u548c\u6587\u672c\u6846\u4e0e\u667a\u80fd\u4f53\u8fdb\u884c\u4e92\u52a8\uff0c\u4f8b\u5982\u70b9\u51fb\u6309\u94ae\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\uff0c\u6216\u5728\u6587\u672c\u6846\u4e2d\u8f93\u5165\u6307\u4ee4\u3002<\/li>\n<li>\u9879\u76ee\u5305\u542b\u591a\u4e2a\u6a21\u5757\uff0c\u5982\u667a\u80fd\u4f53\u6838\u5fc3\u903b\u8f91\u3001\u5de5\u5177\u5e93\u3001\u6a21\u578b\u7b49\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u4fee\u6539\u548c\u6269\u5c55\u3002<\/li>\n<\/ol>\n<h3>\u8be6\u7ec6\u529f\u80fd\u64cd\u4f5c\u6d41\u7a0b<\/h3>\n<ol>\n<li><strong>\u8bbe\u8ba1\u754c\u9762<\/strong>\uff1a\u4f7f\u7528 Qt Designer \u8bbe\u8ba1 GUI \u754c\u9762\uff0c\u6dfb\u52a0\u6240\u9700\u7684\u7ec4\u4ef6\uff08\u5982\u6309\u94ae\u3001\u6587\u672c\u6846\u7b49\uff09\uff0c\u8bbe\u7f6e\u5e03\u5c40\u548c\u6837\u5f0f\u540e\u4fdd\u5b58\u4e3a <code>.ui<\/code> \u6587\u4ef6\u3002<\/li>\n<li><strong>\u8f6c\u6362 UI \u6587\u4ef6<\/strong>\uff1a\u4f7f\u7528 <code>pyuic<\/code> \u5de5\u5177\u5c06 <code>.ui<\/code> \u6587\u4ef6\u8f6c\u6362\u4e3a Python \u4ee3\u7801\uff1a<\/li>\n<\/ol>\n<pre><code>   pyuic5 your_ui_file.ui -o your_python_file.py\r\n<\/code><\/pre>\n<ol start=\"3\">\n<li><strong>\u7f16\u5199\u903b\u8f91\u4ee3\u7801<\/strong>\uff1a\u5728\u751f\u6210\u7684 Python \u6587\u4ef6\u4e2d\u7f16\u5199\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u7b49\u903b\u8f91\u4ee3\u7801\uff0c\u4f8b\u5982\uff0c\u5f53\u7528\u6237\u70b9\u51fb\u6309\u94ae\u65f6\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c\u3002<\/li>\n<\/ol>\n<pre><code>   import sys\r\nfrom PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton\r\nfrom your_python_file import Ui_MainWindow\r\nclass MyApp(QMainWindow, Ui_MainWindow):\r\ndef __init__(self):\r\nsuper().__init__()\r\nself.setupUi(self)\r\nself.button.clicked.connect(self.on_button_click)\r\ndef on_button_click(self):\r\nprint('Button clicked!')\r\nif __name__ == '__main__':\r\napp = QApplication(sys.argv)\r\nwindow = MyApp()\r\nwindow.show()\r\nsys.exit(app.exec_())\r\n<\/code><\/pre>\n<ol start=\"4\">\n<li><strong>\u667a\u80fd\u4f53\u5b9e\u73b0<\/strong>\uff1a\u667a\u80fd\u4f53\u8d1f\u8d23\u5904\u7406\u7528\u6237\u63d0\u4ea4\u7684\u4efb\u52a1\uff0c\u8c03\u7528\u76f8\u5e94\u7684\u5de5\u5177\u6216\u8d44\u6e90\u6765\u5b8c\u6210\u4efb\u52a1\u3002\u667a\u80fd\u4f53\u67b6\u6784\u5305\u62ec\u611f\u77e5\u3001\u89c4\u5212\u3001\u8bb0\u5fc6\u3001\u5de5\u5177\u4f7f\u7528\u548c\u884c\u52a8\u7b49\u5173\u952e\u7ec4\u4ef6\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>AgentClientDemo \u662f\u4e00\u4e2a\u96c6\u6210\u4e86\u667a\u80fd\u4f53\uff08Agent\uff09\u548c\u5ba2\u6237\u7aef\uff08Client\uff09\u529f\u80fd\u7684\u7efc\u5408\u6027 Python \u9879\u76ee\u3002\u8be5\u9879\u76ee\u57fa\u4e8e PyQt \u6846\u67b6\u5f00\u53d1\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u76f4\u89c2\u6613\u7528\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u3002\u901a\u8fc7\u672c\u9879\u76ee\uff0c\u7528\u6237\u53ef\u4ee5\u4f53\u9a8c\u5230\u667a\u80fd\u4f53\u7684\u5f3a\u5927\u529f\u80fd&#8230;<\/p>\n","protected":false},"author":1,"featured_media":61413,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230,201],"class_list":["post-15410","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu","tag-aizhinengti"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/15410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/comments?post=15410"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/15410\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/media\/61413"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/media?parent=15410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/categories?post=15410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/tags?post=15410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}