{"id":2241,"date":"2018-08-21T05:53:13","date_gmt":"2020-02-12T13:58:36","guid":{"rendered":"http:\/\/vip.fxxkpython.com\/?p=2241"},"modified":"2020-02-12T21:58:38","modified_gmt":"2020-02-12T13:58:38","slug":"014c0cbef6","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=2241","title":{"rendered":"\u7528python\u7ed9\u81ea\u5df1\u5199\u4e00\u4e2a\u64cd\u4f5c\u754c\u9762"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\" >Python \u6709\u4e00\u4e2a\u81ea\u5e26\u7684\u5e93\u53eb\u505a tkinter \uff0c\u7528\u5b83\u6211\u4eec\u53ef\u4ee5\u5199\u51fa\u7cfb\u7edf\u7684\u64cd\u4f5c\u754c\u9762\uff0c\u4e0d\u7ba1\u4f60\u662f Mac OS \u7cfb\u7edf\uff0c\u8fd8\u662f Windows \u7cfb\u7edf\uff0c\u5b83\u90fd\u53ef\u4ee5\u751f\u6210\u76f8\u5bf9\u5e94\u7684\u64cd\u4f5c\u754c\u9762\u3002\u8fd9\u5c31\u662f\u6240\u8c13\u7684\u8de8\u5e73\u53f0\u3002<\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"margin-left: 1em;margin-right: 1em;\"><img decoding=\"async\" class=\" aligncenter\"       style=\"box-shadow: rgb(170, 170, 170) 0em 0em 1em 0px;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python4-1581515916.png\" alt=\"python\" title=\"python\"  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u539f\u7406\u5c31\u662f\u6211\u4eec\u4f7f\u7528 Python \u7684\u4ee3\u7801\u53bb\u8c03\u7528 Tkinter\uff0c&nbsp;<span style=\"letter-spacing: 3px;text-align: justify;\">Tkinter \u5df2\u7ecf\u5c01\u88c5\u4e86\u8bbf\u95eeTK\u7684\u63a5\u53e3\uff0c\u8fd9\u4e2a\u63a5\u53e3\u662f\u4e00\u4e2a\u56fe\u5f62\u5e93\uff0c\u652f\u6301\u591a\u4e2a\u64cd\u4f5c\u7cfb\u7edf\uff0c\u901a\u8fc7\u5b83\u6211\u4eec\u5c31\u53ef\u4ee5\u8c03\u7528\u6211\u4eec\u7cfb\u7edf\u672c\u8eab\u7684GUI\u63a5\u53e3\u4e86\u3002<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">\u63a5\u4e0b\u6765\u6211\u4eec\u7528\u4ee3\u7801\u73a9\u4e00\u4e0b\u5427\uff1a<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<pre style=\"background-color: rgb(43, 43, 43);color: rgb(169, 183, 198);font-family: \u5b8b\u4f53;font-size: 12pt;margin-left: 0.5em;margin-right: 0.5em;\"><span style=\"color:#cc7832;\">from <\/span>tkinter <span style=\"color:#cc7832;\">import <\/span>*<br  \/><span style=\"color:#cc7832;\">import <\/span>tkinter.messagebox <span style=\"color:#cc7832;\">as <\/span>messagebox<br  \/><br  \/><span style=\"color:#cc7832;\">class <\/span>MyApp(Frame):<br  \/><br  \/>    <span style=\"color:#cc7832;\">def <\/span><span style=\"color:#b200b2;\">__init__<\/span>(<span style=\"color:#94558d;\">self<\/span><span style=\"color:#cc7832;\">,<\/span>master=<span style=\"color:#cc7832;\">None<\/span>):<br  \/>        Frame.<span style=\"color:#b200b2;\">__init__<\/span>(<span style=\"color:#94558d;\">self<\/span><span style=\"color:#cc7832;\">,<\/span>master)<br  \/>        <span style=\"color:#94558d;\">self<\/span>.pack()<br  \/>        <span style=\"color:#94558d;\">self<\/span>.createWidgets()<br  \/><br  \/>    <span style=\"color:#cc7832;\">def <\/span><span style=\"color:#ffc66d;\">createWidgets<\/span>(<span style=\"color:#94558d;\">self<\/span>):<br  \/>        <span style=\"color:#94558d;\">self<\/span>.helloLabel = Label(<span style=\"color:#94558d;\">self<\/span><span style=\"color:#cc7832;\">,<\/span><span style=\"color:#aa4926;\">text<\/span>=<span style=\"color:#6a8759;\">\"\u4e16\u754c\u4e0a\u6700\u5e05\u7684\u4eba\u662f\u8c01\uff1f\"<\/span>)<br  \/>        <span style=\"color:#94558d;\">self<\/span>.helloLabel.pack()<br  \/>        <span style=\"color:#94558d;\">self<\/span>.quitButton = Button(<span style=\"color:#94558d;\">self<\/span><span style=\"color:#cc7832;\">,<\/span><span style=\"color:#aa4926;\">text<\/span>=<span style=\"color:#6a8759;\">\"\u8c01\u5462\uff1f\"<\/span><span style=\"color:#cc7832;\">,<\/span><span style=\"color:#aa4926;\">command<\/span>=<span style=\"color:#94558d;\">self<\/span>.who)<br  \/>        <span style=\"color:#94558d;\">self<\/span>.quitButton.pack()<br  \/><br  \/>    <span style=\"color:#cc7832;\">def <\/span><span style=\"color:#ffc66d;\">who<\/span>(<span style=\"color:#94558d;\">self<\/span>):<br  \/>        messagebox.showinfo(<span style=\"color:#6a8759;\">\"\u7b54\u6848\"<\/span><span style=\"color:#cc7832;\">,<\/span><span style=\"color:#6a8759;\">\"\u5f53\u7136\u662f\u5c0f\u5e05b\u5566\"<\/span>)<br  \/><br  \/><br  \/>myapp = MyApp()<br  \/>myapp.master.title(<span style=\"color:#6a8759;\">'hello'<\/span>)<br  \/>myapp.mainloop()<\/pre>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><\/span><br  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">\u5728\u8fd9\u91cc\uff1a<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">1 \u6211\u4eec\u5bfc\u5165\u4e86 tkinter \u7684\u76f8\u5173\u6a21\u5757<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">2 \u5b9a\u4e49\u4e86\u521d\u59cb\u5316\u51fd\u6570\uff0c\u901a\u8fc7 pack\uff08\uff09 \u65b9\u6cd5\u5c06\u6211\u4eec\u7684\u7ec4\u4ef6\u4f20\u7ed9\u7236\u5bb9\u5668<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">3 \u81ea\u5b9a\u4e49\u4e00\u4e2a\u521b\u5efa\u7ec4\u4ef6\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u6807\u7b7e\u548c\u4e00\u4e2a\u6309\u94ae\uff0c\u8fd9\u4e2a\u6309\u94ae\u88ab\u70b9\u51fb\u540e\u5c31\u4f1a\u89e6\u53d1 who \u8fd9\u4e2a\u65b9\u6cd5<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">4 \u6211\u4eec\u901a\u8fc7 messagebox \u6765\u663e\u793a\u4e00\u4e2a\u63d0\u793a\u6846<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">5 \u5b9e\u4f8b\u5316\u6211\u4eec\u7684 APP\uff0c\u7136\u540e\u901a\u8fc7\u4e3b\u7ebf\u7a0b\u6765\u76d1\u542c\u6211\u4eec\u7684\u754c\u9762\u64cd\u4f5c<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">\u8fd0\u884c\u540e\u5982\u4e0b\uff1a<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\"><br  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"letter-spacing: 3px;text-align: justify;\">&nbsp;<\/span><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\" aligncenter\"       style=\"box-shadow: rgb(170, 170, 170) 0em 0em 1em 0px;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python9-1581515917.png\" alt=\"python\" title=\"python\"  \/><\/p>\n<p style=\"text-align: center;\"><br  \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\" aligncenter\"       style=\"box-shadow: rgb(170, 170, 170) 0em 0em 1em 0px;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python4-1581515917.png\" alt=\"python\" title=\"python\"  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u597d\u73a9\u4e48\uff1f\u4f60\u4e5f\u53bb\u8bd5\u8bd5\u5427\uff01<\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: center;\"><span style=\"letter-spacing: 3px;text-align: center;\"><br  \/><\/span><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: center;\"><span style=\"letter-spacing: 3px;text-align: center;\"><br  \/><\/span><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: center;\"><span style=\"letter-spacing: 3px;text-align: center;\"><br  \/><\/span><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: center;\"><span style=\"letter-spacing: 3px;text-align: center;\">\u5173\u6ce8\u6211\uff0c\u8ba9\u4f60\u50cf\u770b\u5c0f\u9ec4\u6587\u4e00\u6837\u8f7b\u677e\u5b66\u5230 Python \u7684\u6240\u6709\uff01<\/span><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\" aligncenter\"       style=\"width: 69%;height: auto !important;box-shadow: rgb(170, 170, 170) 0em 0em 1em 0px;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python5-1581515917.jpeg\" alt=\"python\" title=\"python\"  \/><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: center;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: justify;letter-spacing: 3px;\">ps\uff1a\u8fd8\u6ca1\u83b7\u53d6\u6211\u7cbe\u5fc3\u51c6\u5907\u7684 Python \u7535\u5b50\u4e66\u548c\u601d\u7ef4\u5bfc\u56fe\u7b49\u5e72\u8d27\u7684\u53ef\u4ee5\u5728\u6211\u7684\u516c\u4f17\u53f7\u300c\u5b66\u4e60Python\u7684\u6b63\u786e\u59ff\u52bf\u300d\u4e2d\u53d1\u9001 python \u514d\u8d39\u83b7\u53d6\u54e6\uff01&nbsp;<\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: justify;letter-spacing: 3px;\">&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: justify;letter-spacing: 3px;\"><strong>\u518dps:\u8bf4\u771f\u7684\uff0c\u5982\u679c\u4f60\u80fd\u70b9\u4e2a\u8d5e\u8f6c\u53d1\u652f\u6301\u6211\u4e00\u4e0b\u6211\u4f1a\u66f4\u6709\u52a8\u529b\u5199\u3002<\/strong><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: right;letter-spacing: 3px;\"><strong><br  \/><\/strong><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: right;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: right;\"><span style=\"text-align: justify;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img decoding=\"async\" class=\"mpa-image aligncenter\"     style=\"width: 74%;height: auto !important;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python10-1581515918.gif\" alt=\"python\" title=\"python\"  \/><\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<blockquote class=\"keep-source\">\n<p>\u539f\u6587\u59cb\u53d1\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7\uff08\u5b66\u4e60python\u7684\u6b63\u786e\u59ff\u52bf\uff09\uff1a<a target=\"_blank\" href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MzU2ODYzNTkwMg==&#038;mid=2247483912&#038;idx=1&#038;sn=e0f7da15f72d2bab9509f9291075765f&#038;chksm=fc8bba99cbfc338fd42a9dcf7272d7d6a29e2eebadfebdbeb1335b0fe9c4158e43eaa5c97763\">python<\/a><\/p>\n<\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Python \u6709\u4e00\u4e2a\u81ea\u5e26\u7684\u5e93\u53eb\u505a tkinter \uff0c\u7528\u5b83\u6211\u4eec\u53ef\u4ee5\u5199\u51fa\u7cfb\u7edf\u7684\u64cd\u4f5c\u754c\u9762\uff0c\u4e0d\u7ba1\u4f60\u662f Mac OS \u7cfb\u7edf\uff0c\u8fd8\u662f Windows \u7cfb\u7edf\uff0c\u5b83\u90fd\u53ef\u4ee5\u751f\u6210\u76f8\u5bf9\u5e94\u7684\u64cd\u4f5c\u754c\u9762\u3002\u8fd9\u5c31\u662f\u6240\u8c13\u7684\u8de8\u5e73\u53f0\u3002 \u539f\u7406\u5c31\u662f\u6211\u4eec\u4f7f\u7528 Python \u7684\u4ee3\u7801\u53bb\u8c03\u7528 Tkint&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2242,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[303],"tags":[302,19,300,301],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/2241"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2241"}],"version-history":[{"count":1,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/2241\/revisions"}],"predecessor-version":[{"id":2248,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/2241\/revisions\/2248"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/media\/2242"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}