{"id":1918,"date":"2023-11-21T09:48:20","date_gmt":"2023-11-21T01:48:20","guid":{"rendered":"http:\/\/zhang.mba\/?p=1918"},"modified":"2023-11-21T09:49:49","modified_gmt":"2023-11-21T01:49:49","slug":"remi-yi-ge-zi-dong-zhuan-huanpython-dai-ma-weihtml","status":"publish","type":"post","link":"https:\/\/zhang.mba\/index.php\/2023\/11\/21\/09\/48\/20\/1918\/remi-yi-ge-zi-dong-zhuan-huanpython-dai-ma-weihtml\/python\/zhangzhiqi\/","title":{"rendered":"Remi\uff1a\u4e00\u4e2a\u81ea\u52a8\u8f6c\u6362Python\u4ee3\u7801\u4e3aHTML\u754c\u9762\u7684\u7206\u6b3eGUI\u5e93"},"content":{"rendered":"<p><strong>\u5de5\u5177\u6982\u8ff0<\/strong><\/p>\n<p>Remi\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efaPython\u5e94\u7528\u7a0b\u5e8f\u7684GUI\u5e93\uff0c\u5b83\u7684\u754c\u9762\u5728Web\u6d4f\u89c8\u5668\u4e2d\u8fdb\u884c\u6e32\u67d3\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u672c\u5730\u548c\u8fdc\u7a0b\u8bbf\u95ee\u4ed6\u4eec\u7684\u754c\u9762\u3002<\/p>\n<p>Remi\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u521b\u5efa\u8de8\u5e73\u53f0\u7684GUI\u5e94\u7528\uff0c\u800c\u65e0\u9700\u7f16\u5199HTML\u4ee3\u7801\u3002\u5b83\u4f1a\u81ea\u52a8\u5c06\u4f60\u7684Python\u4ee3\u7801\u8f6c\u6362\u4e3aHTML\uff0c\u5e76\u5728\u5e94\u7528\u542f\u52a8\u65f6\u542f\u52a8\u4e00\u4e2aWeb\u670d\u52a1\u5668\uff0c\u4f7f\u5f97\u5e94\u7528\u53ef\u4ee5\u5728\u672c\u5730\u7f51\u7edc\u4e0a\u8bbf\u95ee\u3002<\/p>\n<p><strong>\u57fa\u4e8eWeb\u6d4f\u89c8\u5668\u7684\u754c\u9762\u6e32\u67d3<\/strong><\/p>\n<p>Remi\u5229\u7528Web\u6d4f\u89c8\u5668\u7684\u80fd\u529b\u6765\u6e32\u67d3\u5e94\u7528\u7a0b\u5e8f\u7684\u754c\u9762\u3002\u5f00\u53d1\u8005\u53ea\u9700\u4f7f\u7528Python\u7f16\u5199\u754c\u9762\u7684\u903b\u8f91\u548c\u5e03\u5c40\uff0c\u4e0d\u9700\u8981\u7f16\u5199HTML\u4ee3\u7801\u3002Remi\u4f1a\u81ea\u52a8\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aHTML\uff0c\u5e76\u5c06\u754c\u9762\u6e32\u67d3\u5728Web\u6d4f\u89c8\u5668\u4e2d\u3002<\/p>\n<p>\u8fd9\u6837\u7684\u8bbe\u8ba1\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u5229\u7528Web\u5f00\u53d1\u7684\u4f18\u52bf\uff0c\u5982\u4e30\u5bcc\u7684UI\u7ec4\u4ef6\u548c\u7075\u6d3b\u7684\u5e03\u5c40\uff0c\u540c\u65f6\u4fdd\u6301\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u7684\u4fbf\u5229\u6027\u3002<\/p>\n<p><strong>\u81ea\u52a8\u8f6c\u6362Python\u4ee3\u7801\u4e3aHTML<\/strong><\/p>\n<p>Remi\u63d0\u4f9b\u4e86\u81ea\u52a8\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aHTML\u7684\u529f\u80fd\u3002\u5f00\u53d1\u8005\u53ea\u9700\u8981\u4f7f\u7528Python\u8fdb\u884c\u754c\u9762\u7684\u903b\u8f91\u548c\u5e03\u5c40\u7f16\u5199\uff0cRemi\u4f1a\u81ea\u52a8\u5c06\u4ee3\u7801\u8f6c\u6362\u4e3a\u76f8\u5e94\u7684HTML\u8868\u793a\u3002<\/p>\n<p>\u8fd9\u6837\u7684\u8bbe\u8ba1\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u4e13\u6ce8\u4e8e\u5e94\u7528\u7a0b\u5e8f\u7684\u903b\u8f91\u548c\u529f\u80fd\uff0c\u800c\u65e0\u9700\u8fc7\u591a\u5173\u6ce8HTML\u4ee3\u7801\u7684\u7f16\u5199\u548c\u7ef4\u62a4\u3002<\/p>\n<p><strong>\u5b89\u88c5\u548c\u4f7f\u7528Remi<\/strong><\/p>\n<p>\u8981\u4f7f\u7528Remi\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u5b83\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u754c\u9762\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Remi\uff1a<\/p>\n<\/li>\n<\/ol>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">pip install remi\n<\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528Remi\u521b\u5efaGUI\u5e94\u7528\u7a0b\u5e8f\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">import remi.gui as gui\nfrom remi import start, App\n\nclass MyApp(App):\n    def main(self):\n        # \u521b\u5efa\u4e00\u4e2a\u7a97\u53e3\n        window = gui.VBox(width=300, height=200)\n\n        # \u521b\u5efa\u4e00\u4e2a\u6587\u672c\u6807\u7b7e\n        label = gui.Label('Hello, Remi!', width=200, height=30)\n        window.append(label)\n\n        # \u521b\u5efa\u4e00\u4e2a\u6309\u94ae\n        button = gui.Button('Click me!', width=200, height=30)\n        window.append(button)\n\n        # \u5b9a\u4e49\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\n        def on_button_pressed(widget):\n            label.set_text('Button clicked!')\n\n        # \u7ed1\u5b9a\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\n        button.onclick.connect(on_button_pressed)\n\n        # \u8fd4\u56de\u7a97\u53e3\u4f5c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u754c\u9762\n        return window\n\n# \u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\nstart(MyApp)\n<\/code><\/pre>\n<p>\u8fd0\u884c\u4ee5\u4e0a\u4ee3\u7801\u540e\uff0cRemi\u4f1a\u81ea\u52a8\u542f\u52a8\u4e00\u4e2aWeb\u670d\u52a1\u5668\uff0c\u5e76\u5728\u6d4f\u89c8\u5668\u4e2d\u663e\u793a\u60a8\u7684GUI\u5e94\u7528\u7a0b\u5e8f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee<code>http:\/\/localhost:8081<\/code>\u6765\u8bbf\u95ee\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/VIupIhU5lf7uIeG1uZ7MPXZ2HtlJH4z5uh8V79PaB6noVmlsUCFW0nVswQIvCoqhD7lqF0TZh3UmIwXVHZ5WIw\/640?wx_fmt=png&amp;from=appmsg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/VIupIhU5lf7uIeG1uZ7MPXZ2HtlJH4z5uh8V79PaB6noVmlsUCFW0nVswQIvCoqhD7lqF0TZh3UmIwXVHZ5WIw\/640?wx_fmt=png&amp;from=appmsg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\u56fe\u7247\" \/><\/div><\/p>\n<p><strong>\u672c\u5730\u548c\u8fdc\u7a0b\u8bbf\u95ee\u7684\u4fbf\u5229\u6027<\/strong><\/p>\n<p>\u7531\u4e8eRemi\u7684\u754c\u9762\u5728Web\u6d4f\u89c8\u5668\u4e2d\u8fdb\u884c\u6e32\u67d3\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u672c\u5730\u6216\u8fdc\u7a0b\u7684URL\u6765\u8bbf\u95ee\u4ed6\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u754c\u9762\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u672c\u5730\u673a\u5668\u4e0a\u8fdb\u884c\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u548c\u6d4b\u8bd5\uff0c\u5e76\u901a\u8fc7\u7f51\u7edc\u5c06\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u7ed9\u8fdc\u7a0b\u7528\u6237\u4f7f\u7528\u3002<\/p>\n<p>Remi\u542f\u52a8\u7684Web\u670d\u52a1\u5668\u4f7f\u5f97\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5728\u5c40\u57df\u7f51\u5185\u901a\u8fc7\u6d4f\u89c8\u5668\u8fdb\u884c\u8bbf\u95ee\uff0c\u63d0\u4f9b\u4e86\u7075\u6d3b\u548c\u65b9\u4fbf\u7684\u8bbf\u95ee\u65b9\u5f0f\u3002<\/p>\n<p><strong>\u8de8\u5e73\u53f0\u7684GUI\u5e94\u7528\u5f00\u53d1<\/strong><\/p>\n<p>Remi\u7684\u8bbe\u8ba1\u76ee\u6807\u4e4b\u4e00\u662f\u652f\u6301\u8de8\u5e73\u53f0\u7684GUI\u5e94\u7528\u5f00\u53d1\u3002\u7531\u4e8e\u754c\u9762\u662f\u5728Web\u6d4f\u89c8\u5668\u4e2d\u6e32\u67d3\u7684\uff0cRemi\u5e94\u7528\u53ef\u4ee5\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\uff0c\u5305\u62ecWindows\u3001macOS\u548cLinux\u3002<\/p>\n<p>\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u4ee3\u7801\u548c\u754c\u9762\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u90e8\u7f72\u548c\u4f7f\u7528\u4ed6\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u51cf\u5c11\u4e86\u5f00\u53d1\u548c\u7ef4\u62a4\u7684\u5de5\u4f5c\u91cf\u3002<\/p>\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n<p>Remi\u662f\u4e00\u4e2a\u5f3a\u5927\u4e14\u65b9\u4fbf\u7684Python GUI\u5e93\uff0c\u5b83\u53ef\u4ee5\u5728Web\u6d4f\u89c8\u5668\u4e2d\u6e32\u67d3\u5e94\u7528\u7a0b\u5e8f\u7684\u754c\u9762\u3002\u5b83\u652f\u6301\u672c\u5730\u548c\u8fdc\u7a0b\u8bbf\u95ee\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u521b\u5efa\u8de8\u5e73\u53f0\u7684GUI\u5e94\u7528\u3002<\/p>\n<p>Remi\u81ea\u52a8\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aHTML\uff0c\u7b80\u5316\u4e86\u754c\u9762\u7684\u5f00\u53d1\u8fc7\u7a0b\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u90fd\u53ef\u4ee5\u901a\u8fc7Remi\u8f7b\u677e\u521b\u5efa\u529f\u80fd\u4e30\u5bcc\u7684\u8de8\u5e73\u53f0GUI\u5e94\u7528\u3002<\/p>\n<p>\u6765\u6e90&#8212;-\u5c0f\u767d\u8fd9\u6837\u5b66Python<\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5de5\u5177\u6982\u8ff0 Remi\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efaPython\u5e94\u7528\u7a0b\u5e8f\u7684GUI\u5e93\uff0c\u5b83\u7684\u754c\u9762\u5728Web\u6d4f\u89c8\u5668\u4e2d\u8fdb\u884c\u6e32\u67d3\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u672c\u5730\u548c\u8fdc\u7a0b\u8bbf\u95ee\u4ed6\u4eec\u7684\u754c\u9762\u3002 Remi\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u521b\u5efa\u8de8\u5e73\u53f0\u7684GUI\u5e94\u7528\uff0c\u800c\u65e0\u9700\u7f16\u5199HTML\u4ee3\u7801\u3002\u5b83\u4f1a\u81ea\u52a8\u5c06\u4f60\u7684Python\u4ee3\u7801\u8f6c\u6362\u4e3aHTML\uff0c\u5e76\u5728\u5e94\u7528\u542f\u52a8\u65f6 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[12],"tags":[54],"_links":{"self":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1918"}],"collection":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/comments?post=1918"}],"version-history":[{"count":0,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1918\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/media?parent=1918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/categories?post=1918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/tags?post=1918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}