{"id":44,"date":"2021-09-09T12:21:43","date_gmt":"2021-09-09T04:21:43","guid":{"rendered":"http:\/\/139.155.46.233\/?p=44"},"modified":"2021-09-09T12:23:31","modified_gmt":"2021-09-09T04:23:31","slug":"%e7%ac%ac%e4%b8%80%e4%b8%aa%e7%95%8c%e9%9d%a2","status":"publish","type":"post","link":"https:\/\/www.lucas88.cn\/?p=44","title":{"rendered":"\u7b2c\u4e00\u4e2a\u754c\u9762"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">1\u3001\u5bfc\u5165\u5e93<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nimport PySimpleGUI as sg\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">2\u3001\u5b9a\u4e49\u5e03\u5c40&amp;\u786e\u5b9a\u884c\u6570<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nlayout = &#x5B;\n&#x5B;sg.Text('\u8bf7\u8f93\u5165\u57fa\u672c\u4fe1\u606f\uff01',enable_events=True)],\n&#x5B;sg.Text('\u59d3\u540d'),sg.InputText('\u5f20 \u660e\u660e',key='-name-')],\n&#x5B;sg.Text('\u6027\u522b'),sg.InputText('\u7537',key='-sex-')],\n&#x5B;sg.Text('\u56fd\u7c4d'),sg.InputText('\u4e2d\u56fd')],\n&#x5B;sg.Button('\u786e\u8ba4'),sg.Button('\u53d6\u6d88')],\n&#x5B;sg.Button('\u786e\u8ba41'),sg.Button('1\u53d6\u6d88')]\n]\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">3\u3001\u521b\u5efa\u7a97\u53e3<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nwindow=sg.Window('Window Title',layout)\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">4\u3001\u4e8b\u4ef6\u5faa\u73af<\/h1>\n\n\n\n<p>while True:<br>event,values=window.read()<br>print(event,values)<br>if event==&#8217;\u786e\u8ba4&#8217;:<br>print(&#8216;\u59d3\u540d\uff1a&#8217;,values[&#8216;-name-&#8216;])<br>print(&#8216;\u6027\u522b\uff1a&#8217;,values[&#8216;-sex-&#8216;])<br>print(&#8216;\u59d3\u540d\uff1a&#8217;,values[0])<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nif event==None:\n    break\n#\u5224\u65ad\u4e8b\u4ef6\u662f\u5426\u53d1\u751f\u7684\u51e0\u79cd\u65b9\u5f0f\uff1a\n# if event=='\u53d6\u6d88':\n#   sg.Popup('\u4f60\u70b9\u51fb\u4e86\u53d6\u6d88\uff01')\n#   break\n# if event in ('\u53d6\u6d88',None):\n#   sg.Popup('\u4f60\u70b9\u51fb\u4e86\u53d6\u6d88\u6216\u8005\u5173\u95ed\u6309\u94ae\uff01')\n#   break\n# if event.startswith('\u786e\u8ba4'):\n#   sg.Popup('\u4f60\u70b9\u51fb\u4e86\u786e\u8ba4\u6216\u8005\u786e\u8ba41\u6309\u94ae\uff01')      \n# if event.endswith('\u53d6\u6d88'):\n#   sg.Popup('\u4f60\u70b9\u51fb\u4e86\u53d6\u6d88\u6216\u8005\u53d6\u6d88\u6309\u94ae\uff01')\n#\u5176\u4ed6\u5143\u7d20\u4e8b\u4ef6\uff1a\n# \u50cf\u6587\u672c\u5143\u7d20\uff0c\u8f93\u5165\u6846\uff0c\u4e0b\u62c9\u83dc\u5355\u7b49\u4e8b\u4ef6\u5c5e\u6027\u9ed8\u8ba4\u662f\u5173\u95ed\u7684\u3002\u5f53\u624b\u52a8\u8bbe\u7f6e\u4ed6\u4eec\u7684\u4e8b\u4ef6\u5c5e\u6027enable_events=True\u4e3a\u771f\u65f6\uff0c\n# \u4ed6\u4eec\u4e5f\u5c06\u5177\u6709\u4e8b\u4ef6\u5c5e\u6027\u3002   \n# if event=='\u8bf7\u8f93\u5165\u57fa\u672c\u4fe1\u606f\uff01':\n#   sg.Popup('\u8fd9\u91cc\u662f\u6587\u672c\u5143\u7d20\u70b9\u51fb\u65f6\u5f39\u51fa\uff01')\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">5\u3001\u5173\u95ed\u7a97\u53e3<\/h1>\n\n\n\n<p>window.close()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5bfc\u5165\u5e93 import PySimpleGUI as sg 2\u3001\u5b9a\u4e49\u5e03\u5c40&amp;\u786e\u5b9a\u884c\u6570 layout =&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/www.lucas88.cn\/?p=44\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=44"}],"version-history":[{"count":1,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":45,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions\/45"}],"wp:attachment":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}