{"id":90662,"date":"2026-08-05T19:00:42","date_gmt":"2026-08-05T11:00:42","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/90662.html"},"modified":"2026-08-05T19:00:42","modified_gmt":"2026-08-05T11:00:42","slug":"python-tkinter%ef%bc%9a%e7%bb%99%e4%bb%a3%e7%a0%81%e8%a3%85%e4%b8%aa%e5%8f%af%e8%a7%86%e5%8c%96%e5%a4%96%e5%a3%b3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/90662.html","title":{"rendered":"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d"},"content":{"rendered":"<\/p>\n<h4 id=\"%E6%96%87%E7%AB%A0%E7%9B%AE%E5%BD%95\" style=\"background-color:transparent\">\u6587\u7ae0\u76ee\u5f55<\/h4>\n<p id=\"%F0%9F%93%96%20%E5%89%8D%E8%A8%80-toc\" style=\"margin-left:40px\"><span style=\"color:#0d0016\">&#x1f4d6; \u524d\u8a00<\/span><\/p>\n<p id=\"%E7%AC%AC%E4%B8%80%E7%AB%A0%EF%BC%9A%E5%88%9D%E8%AF%86%20Tkinter%20%E2%80%94%E2%80%94%20%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%AA%97%E5%8F%A3-toc\" style=\"margin-left:40px\"><span style=\"color:#0d0016\">\u7b2c\u4e00\u7ae0&#xff1a;\u521d\u8bc6 Tkinter \u2014\u2014 \u7b2c\u4e00\u4e2a\u7a97\u53e3<\/span><\/p>\n<p id=\"1.1%20%E6%A3%80%E6%9F%A5%20Tkinter%20%E6%98%AF%E5%90%A6%E5%AE%89%E8%A3%85-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">1.1 \u68c0\u67e5 Tkinter \u662f\u5426\u5b89\u88c5<\/span><\/p>\n<p id=\"1.2%20%E5%88%9B%E5%BB%BA%E4%BD%A0%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%AA%97%E5%8F%A3-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">1.2 \u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a\u7a97\u53e3<\/span><\/p>\n<p id=\"%E7%AC%AC%E4%BA%8C%E7%AB%A0%EF%BC%9A%E5%B8%B8%E7%94%A8%E7%BB%84%E4%BB%B6%20%E2%80%94%E2%80%94%20%E6%90%AD%E5%BB%BA%E7%95%8C%E9%9D%A2%E7%9A%84%E2%80%9C%E4%B9%90%E9%AB%98%E7%A7%AF%E6%9C%A8%E2%80%9D-toc\" style=\"margin-left:40px\"><span style=\"color:#0d0016\">\u7b2c\u4e8c\u7ae0&#xff1a;\u5e38\u7528\u7ec4\u4ef6 \u2014\u2014 \u642d\u5efa\u754c\u9762\u7684\u201c\u4e50\u9ad8\u79ef\u6728\u201d<\/span><\/p>\n<p id=\"2.1%20Label%20%E2%80%94%E2%80%94%20%E6%98%BE%E7%A4%BA%E6%96%87%E5%AD%97%E6%88%96%E5%9B%BE%E7%89%87-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">2.1 Label \u2014\u2014 \u663e\u793a\u6587\u5b57\u6216\u56fe\u7247<\/span><\/p>\n<p id=\"2.2%20Button%20%E2%80%94%E2%80%94%20%E7%94%A8%E6%88%B7%E7%82%B9%E5%87%BB%E8%A7%A6%E5%8F%91%E5%8A%A8%E4%BD%9C-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">2.2 Button \u2014\u2014 \u7528\u6237\u70b9\u51fb\u89e6\u53d1\u52a8\u4f5c<\/span><\/p>\n<p id=\"%E5%B1%80%EF%BC%88%E6%9C%80%E5%B8%B8%E7%94%A8%EF%BC%89-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">\u5c40&#xff08;\u6700\u5e38\u7528&#xff09;<\/span><\/p>\n<p id=\"3.3%20place()%20%E2%80%94%E2%80%94%20%E7%B2%BE%E7%A1%AE%E2%80%9C%E5%83%8F%E7%B4%A0%E7%BA%A7%E2%80%9D%E5%AE%9A%E4%BD%8D-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">3.3 place() \u2014\u2014 \u7cbe\u786e\u201c\u50cf\u7d20\u7ea7\u201d\u5b9a\u4f4d<\/span><\/p>\n<p id=\"%E7%AC%AC%E4%B8%89%E7%AB%A0%EF%BC%9A%E5%B8%83%E5%B1%80%E7%AE%A1%E7%90%86%20%E2%80%94%E2%80%94%20%E6%80%8E%E4%B9%88%E6%8A%8A%E4%B8%9C%E8%A5%BF%E2%80%9C%E6%91%86%E5%A5%BD%E7%9C%8B%E2%80%9D-toc\" style=\"margin-left:40px\"><span style=\"color:#0d0016\">\u7b2c\u4e09\u7ae0&#xff1a;\u5e03\u5c40\u7ba1\u7406 \u2014\u2014 \u600e\u4e48\u628a\u4e1c\u897f\u201c\u6446\u597d\u770b\u201d<\/span><\/p>\n<p id=\"3.1%20pack()%20%E2%80%94%E2%80%94%20%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E2%80%9C%E6%8E%92%E9%98%9F%E2%80%9D%E5%B8%83%E5%B1%80-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">3.1 pack() \u2014\u2014 \u6700\u7b80\u5355\u7684\u201c\u6392\u961f\u201d\u5e03\u5c40<\/span><\/p>\n<p id=\"3.2%20grid()%20%E2%80%94%E2%80%94%20%E8%A1%A8%E6%A0%BC%E5%B8%83%E5%B1%80%EF%BC%88%E6%9C%80%E5%B8%B8%E7%94%A8%EF%BC%89-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">3.2 grid() \u2014\u2014 \u8868\u683c\u5e03\u5c40&#xff08;\u6700\u5e38\u7528&#xff09;<\/span><\/p>\n<p id=\"3.3%20place()%20%E2%80%94%E2%80%94%20%E7%B2%BE%E7%A1%AE%E2%80%9C%E5%83%8F%E7%B4%A0%E7%BA%A7%E2%80%9D%E5%AE%9A%E4%BD%8D-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">3.3 place() \u2014\u2014 \u7cbe\u786e\u201c\u50cf\u7d20\u7ea7\u201d\u5b9a\u4f4d<\/span><\/p>\n<p id=\"-toc\" style=\"margin-left:40px\">\n<p id=\"%E7%AC%AC%E5%9B%9B%E7%AB%A0%EF%BC%9A%E4%BA%8B%E4%BB%B6%E7%BB%91%E5%AE%9A%20%E2%80%94%E2%80%94%20%E8%AE%A9%E7%BB%84%E4%BB%B6%E2%80%9C%E6%B4%BB%E2%80%9D%E8%B5%B7%E6%9D%A5-toc\" style=\"margin-left:40px\"><span style=\"color:#0d0016\">\u7b2c\u56db\u7ae0&#xff1a;\u4e8b\u4ef6\u7ed1\u5b9a \u2014\u2014 \u8ba9\u7ec4\u4ef6\u201c\u6d3b\u201d\u8d77\u6765<\/span><\/p>\n<p id=\"%E7%AC%AC%E4%BA%94%E7%AB%A0%EF%BC%9A%E7%94%BB%E5%B8%83%20Canvas%20%E2%80%94%E2%80%94%20%E8%AE%A9%E7%A8%8B%E5%BA%8F%E5%AD%A6%E4%BC%9A%E2%80%9C%E7%94%BB%E7%94%BB%E2%80%9D-toc\" style=\"margin-left:40px\"><span style=\"color:#0d0016\">\u7b2c\u4e94\u7ae0&#xff1a;\u753b\u5e03 Canvas \u2014\u2014 \u8ba9\u7a0b\u5e8f\u5b66\u4f1a\u201c\u753b\u753b\u201d<\/span><\/p>\n<p id=\"5.1%20%E5%88%9B%E5%BB%BA%E7%94%BB%E5%B8%83-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">5.1 \u521b\u5efa\u753b\u5e03<\/span><\/p>\n<p id=\"5.2%20%E5%9D%90%E6%A0%87%E7%B3%BB%E7%BB%9F%EF%BC%88%E5%85%B3%E9%94%AE%EF%BC%81%EF%BC%89-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">5.2 \u5750\u6807\u7cfb\u7edf&#xff08;\u5173\u952e&#xff01;&#xff09;<\/span><\/p>\n<p id=\"5.3%20%E5%B8%B8%E7%94%A8%E7%BB%98%E5%9B%BE%E6%96%B9%E6%B3%95-toc\" style=\"margin-left:80px\"><span style=\"color:#0d0016\">5.3 \u5e38\u7528\u7ed8\u56fe\u65b9\u6cd5<\/span><\/p>\n<p id=\"%F0%9F%A7%81%20%E7%BB%93%E5%B0%BE-toc\" style=\"margin-left:40px\"><span style=\"color:#0d0016\">&#x1f9c1; \u7ed3\u5c3e<\/span><\/p>\n<hr id=\"hr-toc\" \/>\n<\/p>\n<h2 id=\"\"><\/h2>\n<h3 id=\"%F0%9F%93%96%20%E5%89%8D%E8%A8%80\" style=\"background-color:transparent\">&#x1f4d6; \u524d\u8a00<\/h3>\n<p>\u5199\u4e86\u8fd9\u4e48\u4e45\u7684\u4ee3\u7801&#xff0c;\u4f60\u4e00\u76f4\u5bf9\u7740\u90a3\u4e2a\u9ed1\u4e4e\u4e4e\u7684\u7ec8\u7aef\u7a97\u53e3\u2014\u2014\u8f93\u5165\u4e00\u884c&#xff0c;\u8f93\u51fa\u4e00\u884c&#xff0c;\u50cf\u5728\u7528\u5bf9\u8bb2\u673a\u8ddf\u7535\u8111\u8bf4\u8bdd\u3002<\/p>\n<p>\u4f60\u4e0d\u89c9\u5f97\u6709\u70b9\u5bd2\u9178\u5417&#xff1f;<\/p>\n<p>\u522b\u4eba\u6253\u5f00\u4e00\u4e2a\u8f6f\u4ef6&#xff0c;\u6709\u6309\u94ae\u3001\u6709\u8f93\u5165\u6846\u3001\u6709\u6f02\u4eae\u7684\u754c\u9762&#xff0c;\u70b9\u4e00\u70b9\u5c31\u80fd\u64cd\u4f5c\u3002\u800c\u4f60\u5199\u7684\u7a0b\u5e8f&#xff0c;\u8fd8\u5f97\u8ba9\u7528\u6237\u6253\u5f00\u547d\u4ee4\u884c&#xff0c;\u6572\u00a0python xxx.py&#xff0c;\u7136\u540e\u76ef\u7740\u51e0\u884c\u6587\u5b57\u53d1\u5446\u3002<\/p>\n<p>\u8fd9\u4e0d\u53eb\u201c\u8f6f\u4ef6\u201d&#xff0c;\u8fd9\u53eb\u201c\u811a\u672c\u201d\u3002<\/p>\n<p>\u4eca\u5929\u6211\u4eec\u8981\u5b66\u7684\u00a0tkinter&#xff0c;\u5c31\u662f\u5e2e\u4f60\u7684\u4ee3\u7801\u88c5\u4e0a\u4e00\u4e2a\u53ef\u89c6\u5316\u5916\u58f3\u2014\u2014\u8ba9\u7528\u6237\u80fd\u7528\u9f20\u6807\u70b9\u3001\u7528\u952e\u76d8\u6572\u3001\u7528\u773c\u775b\u770b&#xff0c;\u800c\u4e0d\u662f\u5bf9\u7740\u547d\u4ee4\u884c\u731c\u8c1c\u3002<\/p>\n<p>Tkinter \u662f Python\u00a0\u81ea\u5e26\u7684 GUI \u5e93&#xff0c;\u4e0d\u9700\u8981\u989d\u5916\u5b89\u88c5&#xff0c;\u5bfc\u5165\u5c31\u80fd\u7528\u3002\u5b83\u8de8\u5e73\u53f0&#xff0c;Windows\u3001macOS\u3001Linux \u90fd\u80fd\u8dd1\u3002\u867d\u7136\u957f\u5f97\u4e0d\u7b97\u60ca\u8273&#xff0c;\u4f46\u80dc\u5728\u7b80\u5355\u3001\u591f\u7528\u3001\u4e0d\u7528\u6298\u817e\u3002<\/p>\n<p>\u4eca\u5929\u5c31\u5e26\u4f60\u628a Tkinter \u7684\u57fa\u7840\u6478\u4e00\u904d&#xff1a;\u521b\u5efa\u7a97\u53e3\u3001\u5e38\u7528\u7ec4\u4ef6\u3001\u5e03\u5c40\u7ba1\u7406\u3001\u4e8b\u4ef6\u7ed1\u5b9a\u3002<\/p>\n<p>\u8ba9\u4f60\u7684\u4ee3\u7801\u4ece\u6b64\u201c\u6709\u5934\u6709\u8138\u201d\u3002start show&#xff01;&#x1f5a5;\ufe0f<\/p>\n<hr \/>\n<h3 id=\"%E7%AC%AC%E4%B8%80%E7%AB%A0%EF%BC%9A%E5%88%9D%E8%AF%86%20Tkinter%20%E2%80%94%E2%80%94%20%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%AA%97%E5%8F%A3\">\u7b2c\u4e00\u7ae0&#xff1a;\u521d\u8bc6 Tkinter \u2014\u2014 \u7b2c\u4e00\u4e2a\u7a97\u53e3<\/h3>\n<h4 id=\"1.1%20%E6%A3%80%E6%9F%A5%20Tkinter%20%E6%98%AF%E5%90%A6%E5%AE%89%E8%A3%85\">1.1 \u68c0\u67e5 Tkinter \u662f\u5426\u5b89\u88c5<\/h4>\n<p>\u56e0\u4e3a Tkinter \u662f Python \u81ea\u5e26\u7684&#xff0c;\u6240\u4ee5\u5927\u6982\u7387\u5df2\u7ecf\u6709\u4e86\u3002\u4e0d\u653e\u5fc3\u7684\u8bdd\u53ef\u4ee5\u9a8c\u8bc1\u4e00\u4e0b&#xff1a;<\/p>\n<p>python<\/p>\n<p>import tkinter<br \/>\nprint(f&#034;Tkinter \u7248\u672c: {tkinter.TkVersion}&#034;) <\/p>\n<p>\u80fd\u6253\u5370\u51fa\u7248\u672c\u53f7\u5c31\u8bf4\u660e\u6ca1\u95ee\u9898\u3002<\/p>\n<h4 id=\"1.2%20%E5%88%9B%E5%BB%BA%E4%BD%A0%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%AA%97%E5%8F%A3\">1.2 \u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a\u7a97\u53e3<\/h4>\n<p>\u521b\u5efa\u4e00\u4e2a\u7a97\u53e3&#xff0c;\u53ea\u9700\u8981\u56db\u884c\u4ee3\u7801&#xff1a;<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p># \u521b\u5efa\u4e3b\u7a97\u53e3 \u2014\u2014 \u8fd9\u5c31\u662f\u4f60\u7a0b\u5e8f\u7684\u201c\u753b\u5e03\u201d<br \/>\nroot &#061; tk.Tk()<\/p>\n<p># \u7ed9\u7a97\u53e3\u8d77\u4e2a\u540d\u5b57<br \/>\nroot.title(&#034;\u6211\u7684\u7b2c\u4e00\u4e2a GUI \u7a0b\u5e8f&#034;)<\/p>\n<p># \u8bbe\u7f6e\u7a97\u53e3\u5927\u5c0f&#xff08;\u5bbd x \u9ad8&#xff09;<br \/>\nroot.geometry(&#034;400&#215;300&#034;)<\/p>\n<p># \u542f\u52a8\u6d88\u606f\u5faa\u73af \u2014\u2014 \u8ba9\u7a97\u53e3\u4e00\u76f4\u663e\u793a\u7740&#xff0c;\u522b\u95ea\u9000<br \/>\nroot.mainloop() <\/p>\n<p>\u8fd0\u884c\u8fd9\u6bb5\u4ee3\u7801&#xff0c;\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u771f\u6b63\u7684\u7a97\u53e3\u51fa\u73b0\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n<p>&#x1f4cc; \u522b\u5c0f\u770b\u8fd9\u51e0\u884c\u4ee3\u7801&#xff0c;\u8fd9\u53ef\u80fd\u662f\u4f60\u7b2c\u4e00\u6b21\u8ba9 Python \u5f39\u51fa\u4e00\u4e2a\u201c\u6b63\u7ecf\u7684\u684c\u9762\u5e94\u7528\u201d\u3002\u00a0mainloop()\u00a0\u662f\u5173\u952e\u2014\u2014\u6ca1\u6709\u5b83&#xff0c;\u7a97\u53e3\u4e00\u95ea\u5c31\u6ca1\u4e86\u3002\u5b83\u5c31\u50cf\u7535\u996d\u7172\u7684\u201c\u4fdd\u6e29\u201d\u6309\u94ae&#xff0c;\u8ba9\u7a0b\u5e8f\u4e00\u76f4\u8fd0\u884c&#xff0c;\u968f\u65f6\u54cd\u5e94\u4f60\u7684\u64cd\u4f5c\u3002<\/p>\n<h3 id=\"%E7%AC%AC%E4%BA%8C%E7%AB%A0%EF%BC%9A%E5%B8%B8%E7%94%A8%E7%BB%84%E4%BB%B6%20%E2%80%94%E2%80%94%20%E6%90%AD%E5%BB%BA%E7%95%8C%E9%9D%A2%E7%9A%84%E2%80%9C%E4%B9%90%E9%AB%98%E7%A7%AF%E6%9C%A8%E2%80%9D\">\u7b2c\u4e8c\u7ae0&#xff1a;\u5e38\u7528\u7ec4\u4ef6 \u2014\u2014 \u642d\u5efa\u754c\u9762\u7684\u201c\u4e50\u9ad8\u79ef\u6728\u201d<\/h3>\n<p>\u7a97\u53e3\u6709\u4e86&#xff0c;\u4f46\u5b83\u662f\u7a7a\u7684\u3002\u5f80\u91cc\u9762\u52a0\u4e1c\u897f&#xff0c;\u5c31\u8981\u7528\u5230\u00a0\u7ec4\u4ef6&#xff08;Widget&#xff09;\u00a0\u3002Tkinter \u63d0\u4f9b\u4e86\u5341\u51e0\u79cd\u6838\u5fc3\u7ec4\u4ef6&#xff0c;\u5e38\u7528\u7684\u5c31\u4e0b\u9762\u51e0\u4e2a\u3002<\/p>\n<p>\u8fd9\u91cc\u987a\u4fbf\u63d0\u4e00\u53e5&#xff1a;Canvas&#xff08;\u753b\u5e03\u7ec4\u4ef6&#xff09;\u4e5f\u662f\u00a0tkinter\u00a0\u6a21\u5757\u91cc\u7684&#xff0c;\u548c\u00a0Label\u3001Button\u00a0\u662f\u5e73\u7ea7\u5173\u7cfb&#xff0c;\u90fd\u662f\u00a0tkinter\u00a0\u4e0b\u7684\u7c7b\u3002\u540e\u9762\u8bb2\u753b\u56fe\u7684\u65f6\u5019\u4f1a\u5355\u72ec\u5c55\u5f00\u3002<\/p>\n<h4 id=\"2.1%20Label%20%E2%80%94%E2%80%94%20%E6%98%BE%E7%A4%BA%E6%96%87%E5%AD%97%E6%88%96%E5%9B%BE%E7%89%87\">2.1 Label \u2014\u2014 \u663e\u793a\u6587\u5b57\u6216\u56fe\u7247<\/h4>\n<p>Label\u00a0\u5c31\u662f\u7528\u6765\u663e\u793a\u9759\u6001\u6587\u672c\u7684&#xff0c;\u7528\u6237\u6ca1\u6cd5\u6539&#xff0c;\u53ea\u80fd\u770b\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;\u6807\u7b7e\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;200&#034;)<\/p>\n<p># \u521b\u5efa\u6807\u7b7e<br \/>\nlabel &#061; tk.Label(root, text&#061;&#034;\u6b22\u8fce\u6765\u5230 Python GUI \u4e16\u754c&#xff01;&#034;, font&#061;(&#034;\u5fae\u8f6f\u96c5\u9ed1&#034;, 16))<br \/>\nlabel.pack(pady&#061;20)   # pady \u662f\u4e0a\u4e0b\u5916\u8fb9\u8ddd<\/p>\n<p>root.mainloop() <\/p>\n<p>&#x1f4cc;\u00a0pack()\u00a0\u662f\u5e03\u5c40\u65b9\u6cd5&#xff0c;\u6682\u65f6\u7406\u89e3\u4e3a\u201c\u628a\u6807\u7b7e\u653e\u4e0a\u53bb\u201d\u5c31\u884c\u3002pady&#061;20\u00a0\u8ba9\u6807\u7b7e\u79bb\u4e0a\u4e0b\u8fb9\u754c\u6709\u70b9\u8ddd\u79bb&#xff0c;\u4e0d\u90a3\u4e48\u6324\u3002<\/p>\n<h4 id=\"2.2%20Button%20%E2%80%94%E2%80%94%20%E7%94%A8%E6%88%B7%E7%82%B9%E5%87%BB%E8%A7%A6%E5%8F%91%E5%8A%A8%E4%BD%9C\">2.2 Button \u2014\u2014 \u7528\u6237\u70b9\u51fb\u89e6\u53d1\u52a8\u4f5c<\/h4>\n<p>Button\u00a0\u662f\u4ea4\u4e92\u7684\u6838\u5fc3\u2014\u2014\u7528\u6237\u70b9\u4e00\u4e0b&#xff0c;\u7a0b\u5e8f\u5e72\u4e00\u4ef6\u4e8b\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>def on_click():<br \/>\n    print(&#034;\u6309\u94ae\u88ab\u70b9\u51fb\u4e86&#xff01;&#034;)<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;\u6309\u94ae\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;200&#034;)<\/p>\n<p>btn &#061; tk.Button(root, text&#061;&#034;\u70b9\u6211\u4e00\u4e0b&#034;, command&#061;on_click)<br \/>\nbtn.pack(pady&#061;50)<\/p>\n<p>root.mainloop() <\/p>\n<p>&#x1f4cc;\u00a0command\u00a0\u53c2\u6570\u6307\u5b9a\u70b9\u51fb\u540e\u6267\u884c\u54ea\u4e2a\u51fd\u6570&#xff0c;\u6ce8\u610f\u4e0d\u8981\u52a0\u62ec\u53f7\u2014\u2014\u5199\u00a0on_click\u00a0\u800c\u4e0d\u662f\u00a0on_click()\u3002\u52a0\u4e86\u62ec\u53f7\u51fd\u6570\u4f1a\u5728\u521b\u5efa\u6309\u94ae\u65f6\u5c31\u6267\u884c&#xff0c;\u800c\u4e0d\u662f\u7b49\u7528\u6237\u70b9\u51fb\u3002<\/p>\n<\/p>\n<h4 id=\"%E5%B1%80%EF%BC%88%E6%9C%80%E5%B8%B8%E7%94%A8%EF%BC%89\">\u5c40&#xff08;\u6700\u5e38\u7528&#xff09;<\/h4>\n<p>grid()\u00a0\u628a\u7a97\u53e3\u60f3\u8c61\u6210\u4e00\u5f20\u8868\u683c&#xff0c;\u6309\u884c\u548c\u5217\u6446\u653e\u7ec4\u4ef6\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;grid \u5e03\u5c40\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;150&#034;)<\/p>\n<p># \u7b2c0\u884c&#xff1a;\u7528\u6237\u540d<br \/>\ntk.Label(root, text&#061;&#034;\u7528\u6237\u540d&#xff1a;&#034;).grid(row&#061;0, column&#061;0, padx&#061;5, pady&#061;5)<br \/>\ntk.Entry(root, width&#061;20).grid(row&#061;0, column&#061;1, padx&#061;5, pady&#061;5)<\/p>\n<p># \u7b2c1\u884c&#xff1a;\u5bc6\u7801<br \/>\ntk.Label(root, text&#061;&#034;\u5bc6\u7801&#xff1a;&#034;).grid(row&#061;1, column&#061;0, padx&#061;5, pady&#061;5)<br \/>\ntk.Entry(root, width&#061;20, show&#061;&#034;*&#034;).grid(row&#061;1, column&#061;1, padx&#061;5, pady&#061;5)<\/p>\n<p># \u7b2c2\u884c&#xff1a;\u6309\u94ae&#xff08;\u8de8\u4e24\u5217\u5c45\u4e2d&#xff09;<br \/>\ntk.Button(root, text&#061;&#034;\u767b\u5f55&#034;).grid(row&#061;2, column&#061;0, columnspan&#061;2, pady&#061;10)<\/p>\n<p>root.mainloop() <\/p>\n<p>&#x1f4cc;\u00a0grid()\u00a0\u662f\u5b9e\u9645\u5f00\u53d1\u4e2d\u6700\u5e38\u7528\u7684\u5e03\u5c40\u65b9\u5f0f&#xff0c;\u56e0\u4e3a\u8868\u683c\u7ed3\u6784\u6700\u7b26\u5408\u4eba\u7c7b\u7684\u89c6\u89c9\u4e60\u60ef\u3002columnspan&#061;2\u00a0\u8ba9\u6309\u94ae\u8de8\u4e24\u5217\u5c45\u4e2d\u3002<\/p>\n<h4 id=\"3.3%20place()%20%E2%80%94%E2%80%94%20%E7%B2%BE%E7%A1%AE%E2%80%9C%E5%83%8F%E7%B4%A0%E7%BA%A7%E2%80%9D%E5%AE%9A%E4%BD%8D\">3.3 place() \u2014\u2014 \u7cbe\u786e\u201c\u50cf\u7d20\u7ea7\u201d\u5b9a\u4f4d<\/h4>\n<p>place()\u00a0\u7528\u00a0x\u3001y \u5750\u6807\u7cbe\u786e\u5b9a\u4f4d\u7ec4\u4ef6\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;place \u5e03\u5c40\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;200&#034;)<\/p>\n<p>tk.Button(root, text&#061;&#034;\u5de6\u4e0a\u89d2&#034;).place(x&#061;10, y&#061;10)<br \/>\ntk.Button(root, text&#061;&#034;\u53f3\u4e0b\u89d2&#034;).place(x&#061;200, y&#061;150)<\/p>\n<p>root.mainloop() <\/p>\n<p>\u26a0\ufe0f\u00a0place()\u00a0\u6700\u7075\u6d3b\u4f46\u4e5f\u6700\u9ebb\u70e6\u2014\u2014\u7a97\u53e3\u5927\u5c0f\u4e00\u53d8&#xff0c;\u4f4d\u7f6e\u5c31\u5168\u4e71\u4e86\u3002\u65b0\u624b\u4f18\u5148\u7528\u00a0grid()&#xff0c;\u7701\u5fc3\u3002<\/p>\n<h3 id=\"%E7%AC%AC%E4%B8%89%E7%AB%A0%EF%BC%9A%E5%B8%83%E5%B1%80%E7%AE%A1%E7%90%86%20%E2%80%94%E2%80%94%20%E6%80%8E%E4%B9%88%E6%8A%8A%E4%B8%9C%E8%A5%BF%E2%80%9C%E6%91%86%E5%A5%BD%E7%9C%8B%E2%80%9D\">\u7b2c\u4e09\u7ae0&#xff1a;\u5e03\u5c40\u7ba1\u7406 \u2014\u2014 \u600e\u4e48\u628a\u4e1c\u897f\u201c\u6446\u597d\u770b\u201d<\/h3>\n<p>\u7ec4\u4ef6\u521b\u5efa\u4e86&#xff0c;\u4f46\u5f80\u7a97\u53e3\u4e0a\u653e\u7684\u65f6\u5019&#xff0c;\u4f60\u5f97\u544a\u8bc9 Tkinter\u00a0\u653e\u54ea\u513f\u3001\u600e\u4e48\u653e\u3002Tkinter \u63d0\u4f9b\u4e86\u4e09\u79cd\u5e03\u5c40\u7ba1\u7406\u5668\u3002<\/p>\n<h4 id=\"3.1%20pack()%20%E2%80%94%E2%80%94%20%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E2%80%9C%E6%8E%92%E9%98%9F%E2%80%9D%E5%B8%83%E5%B1%80\">3.1 pack() \u2014\u2014 \u6700\u7b80\u5355\u7684\u201c\u6392\u961f\u201d\u5e03\u5c40<\/h4>\n<p>pack()\u00a0\u662f\u6700\u57fa\u7840\u7684\u5e03\u5c40\u65b9\u5f0f\u2014\u2014\u7ec4\u4ef6\u6309\u6dfb\u52a0\u987a\u5e8f\u4ece\u4e0a\u5230\u4e0b\u6392\u961f\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;pack \u5e03\u5c40\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;200&#034;)<\/p>\n<p>tk.Label(root, text&#061;&#034;\u7b2c\u4e00\u4e2a&#034;, bg&#061;&#034;red&#034;).pack(fill&#061;tk.X)<br \/>\ntk.Label(root, text&#061;&#034;\u7b2c\u4e8c\u4e2a&#034;, bg&#061;&#034;green&#034;).pack(fill&#061;tk.X)<br \/>\ntk.Label(root, text&#061;&#034;\u7b2c\u4e09\u4e2a&#034;, bg&#061;&#034;blue&#034;).pack(fill&#061;tk.X)<\/p>\n<p>root.mainloop() <\/p>\n<p>fill&#061;tk.X\u00a0\u8ba9\u6807\u7b7e\u6a2a\u5411\u62c9\u6ee1\u3002side&#061;tk.LEFT\u00a0\u53ef\u4ee5\u8ba9\u7ec4\u4ef6\u6c34\u5e73\u6392\u5217\u3002<\/p>\n<h4 id=\"3.2%20grid()%20%E2%80%94%E2%80%94%20%E8%A1%A8%E6%A0%BC%E5%B8%83%E5%B1%80%EF%BC%88%E6%9C%80%E5%B8%B8%E7%94%A8%EF%BC%89\">3.2 grid() \u2014\u2014 \u8868\u683c\u5e03\u5c40&#xff08;\u6700\u5e38\u7528&#xff09;<\/h4>\n<p>grid()\u00a0\u628a\u7a97\u53e3\u60f3\u8c61\u6210\u4e00\u5f20\u8868\u683c&#xff0c;\u6309\u884c\u548c\u5217\u6446\u653e\u7ec4\u4ef6\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;grid \u5e03\u5c40\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;150&#034;)<\/p>\n<p># \u7b2c0\u884c&#xff1a;\u7528\u6237\u540d<br \/>\ntk.Label(root, text&#061;&#034;\u7528\u6237\u540d&#xff1a;&#034;).grid(row&#061;0, column&#061;0, padx&#061;5, pady&#061;5)<br \/>\ntk.Entry(root, width&#061;20).grid(row&#061;0, column&#061;1, padx&#061;5, pady&#061;5)<\/p>\n<p># \u7b2c1\u884c&#xff1a;\u5bc6\u7801<br \/>\ntk.Label(root, text&#061;&#034;\u5bc6\u7801&#xff1a;&#034;).grid(row&#061;1, column&#061;0, padx&#061;5, pady&#061;5)<br \/>\ntk.Entry(root, width&#061;20, show&#061;&#034;*&#034;).grid(row&#061;1, column&#061;1, padx&#061;5, pady&#061;5)<\/p>\n<p># \u7b2c2\u884c&#xff1a;\u6309\u94ae&#xff08;\u8de8\u4e24\u5217\u5c45\u4e2d&#xff09;<br \/>\ntk.Button(root, text&#061;&#034;\u767b\u5f55&#034;).grid(row&#061;2, column&#061;0, columnspan&#061;2, pady&#061;10)<\/p>\n<p>root.mainloop() <\/p>\n<p>&#x1f4cc;\u00a0grid()\u00a0\u662f\u5b9e\u9645\u5f00\u53d1\u4e2d\u6700\u5e38\u7528\u7684\u5e03\u5c40\u65b9\u5f0f&#xff0c;\u56e0\u4e3a\u8868\u683c\u7ed3\u6784\u6700\u7b26\u5408\u4eba\u7c7b\u7684\u89c6\u89c9\u4e60\u60ef\u3002columnspan&#061;2\u00a0\u8ba9\u6309\u94ae\u8de8\u4e24\u5217\u5c45\u4e2d\u3002<\/p>\n<h4 id=\"3.3%20place()%20%E2%80%94%E2%80%94%20%E7%B2%BE%E7%A1%AE%E2%80%9C%E5%83%8F%E7%B4%A0%E7%BA%A7%E2%80%9D%E5%AE%9A%E4%BD%8D\">3.3 place() \u2014\u2014 \u7cbe\u786e\u201c\u50cf\u7d20\u7ea7\u201d\u5b9a\u4f4d<\/h4>\n<p>place()\u00a0\u7528\u00a0x\u3001y \u5750\u6807\u7cbe\u786e\u5b9a\u4f4d\u7ec4\u4ef6\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;place \u5e03\u5c40\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;200&#034;)<\/p>\n<p>tk.Button(root, text&#061;&#034;\u5de6\u4e0a\u89d2&#034;).place(x&#061;10, y&#061;10)<br \/>\ntk.Button(root, text&#061;&#034;\u53f3\u4e0b\u89d2&#034;).place(x&#061;200, y&#061;150)<\/p>\n<p>root.mainloop() <\/p>\n<p>\u26a0\ufe0f\u00a0place()\u00a0\u6700\u7075\u6d3b\u4f46\u4e5f\u6700\u9ebb\u70e6\u2014\u2014\u7a97\u53e3\u5927\u5c0f\u4e00\u53d8&#xff0c;\u4f4d\u7f6e\u5c31\u5168\u4e71\u4e86\u3002\u65b0\u624b\u4f18\u5148\u7528\u00a0grid()&#xff0c;\u7701\u5fc3\u3002<\/p>\n<h3 id=\"\"><\/h3>\n<h3 id=\"%E7%AC%AC%E5%9B%9B%E7%AB%A0%EF%BC%9A%E4%BA%8B%E4%BB%B6%E7%BB%91%E5%AE%9A%20%E2%80%94%E2%80%94%20%E8%AE%A9%E7%BB%84%E4%BB%B6%E2%80%9C%E6%B4%BB%E2%80%9D%E8%B5%B7%E6%9D%A5\" style=\"background-color:transparent\">\u7b2c\u56db\u7ae0&#xff1a;\u4e8b\u4ef6\u7ed1\u5b9a \u2014\u2014 \u8ba9\u7ec4\u4ef6\u201c\u6d3b\u201d\u8d77\u6765<\/h3>\n<p>\u524d\u9762\u6309\u94ae\u7684\u00a0command\u00a0\u53ea\u80fd\u5904\u7406\u70b9\u51fb\u4e8b\u4ef6\u3002\u5982\u679c\u60f3\u5904\u7406\u952e\u76d8\u6309\u952e\u3001\u9f20\u6807\u60ac\u505c\u3001\u53cc\u51fb\u7b49\u66f4\u591a\u4ea4\u4e92&#xff0c;\u5c31\u8981\u7528\u00a0bind()\u00a0\u65b9\u6cd5\u3002<\/p>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>def on_key_press(event):<br \/>\n    print(f&#034;\u6309\u4e0b\u4e86\u952e&#xff1a;{event.char}&#034;)<\/p>\n<p>def on_enter(event):<br \/>\n    print(&#034;\u9f20\u6807\u8fdb\u5165\u6309\u94ae\u533a\u57df&#034;)<\/p>\n<p>def on_leave(event):<br \/>\n    print(&#034;\u9f20\u6807\u79bb\u5f00\u6309\u94ae\u533a\u57df&#034;)<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;\u4e8b\u4ef6\u7ed1\u5b9a\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;300&#215;200&#034;)<\/p>\n<p># \u7ed1\u5b9a\u952e\u76d8\u4e8b\u4ef6\u5230\u6574\u4e2a\u7a97\u53e3<br \/>\nroot.bind(&#034;&lt;Key&gt;&#034;, on_key_press)<\/p>\n<p>btn &#061; tk.Button(root, text&#061;&#034;\u628a\u9f20\u6807\u653e\u4e0a\u6765\u8bd5\u8bd5&#034;)<br \/>\nbtn.pack(pady&#061;50)<\/p>\n<p># \u7ed1\u5b9a\u9f20\u6807\u8fdb\u5165\u548c\u79bb\u5f00\u4e8b\u4ef6<br \/>\nbtn.bind(&#034;&lt;Enter&gt;&#034;, on_enter)<br \/>\nbtn.bind(&#034;&lt;Leave&gt;&#034;, on_leave)<\/p>\n<p>root.mainloop() <\/p>\n<p>\u5e38\u7528\u4e8b\u4ef6\u7c7b\u578b&#xff1a;<\/p>\n<table>\n<tr>\u4e8b\u4ef6\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>&lt;Button-1&gt;<\/td>\n<td>\u5355\u51fb\u9f20\u6807\u5de6\u952e<\/td>\n<\/tr>\n<tr>\n<td>&lt;Double-Button-1&gt;<\/td>\n<td>\u53cc\u51fb\u9f20\u6807\u5de6\u952e<\/td>\n<\/tr>\n<tr>\n<td>&lt;Key&gt;<\/td>\n<td>\u6309\u4e0b\u4efb\u610f\u952e<\/td>\n<\/tr>\n<tr>\n<td>&lt;Return&gt;<\/td>\n<td>\u6309\u4e0b\u56de\u8f66\u952e<\/td>\n<\/tr>\n<tr>\n<td>&lt;Enter&gt;<\/td>\n<td>\u9f20\u6807\u8fdb\u5165\u7ec4\u4ef6\u533a\u57df<\/td>\n<\/tr>\n<tr>\n<td>&lt;Leave&gt;<\/td>\n<td>\u9f20\u6807\u79bb\u5f00\u7ec4\u4ef6\u533a\u57df<\/td>\n<\/tr>\n<tr>\n<td>&lt;B1-Motion&gt;<\/td>\n<td>\u6309\u4f4f\u5de6\u952e\u62d6\u52a8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"%E7%AC%AC%E4%BA%94%E7%AB%A0%EF%BC%9A%E7%94%BB%E5%B8%83%20Canvas%20%E2%80%94%E2%80%94%20%E8%AE%A9%E7%A8%8B%E5%BA%8F%E5%AD%A6%E4%BC%9A%E2%80%9C%E7%94%BB%E7%94%BB%E2%80%9D\">\u7b2c\u4e94\u7ae0&#xff1a;\u753b\u5e03 Canvas \u2014\u2014 \u8ba9\u7a0b\u5e8f\u5b66\u4f1a\u201c\u753b\u753b\u201d<\/h3>\n<p>\u524d\u9762\u6211\u4eec\u63d0\u5230&#xff0c;Canvas\u00a0\u4e5f\u662f\u00a0tkinter\u00a0\u6a21\u5757\u4e0b\u7684\u4e00\u4e2a\u7ec4\u4ef6\u7c7b&#xff0c;\u548c\u00a0Label\u3001Button\u00a0\u662f\u5e73\u7ea7\u5173\u7cfb\u3002\u5b83\u5c31\u50cf\u4e00\u5757\u865a\u62df\u7684\u767d\u677f&#xff0c;\u76f4\u7ebf\u3001\u77e9\u5f62\u3001\u5706\u5f62\u3001\u6587\u5b57&#xff0c;\u60f3\u753b\u4ec0\u4e48\u90fd\u884c\u3002<\/p>\n<h4 id=\"5.1%20%E5%88%9B%E5%BB%BA%E7%94%BB%E5%B8%83\">5.1 \u521b\u5efa\u753b\u5e03<\/h4>\n<p>python<\/p>\n<p>import tkinter as tk<\/p>\n<p>root &#061; tk.Tk()<br \/>\nroot.title(&#034;\u753b\u5e03\u793a\u4f8b&#034;)<br \/>\nroot.geometry(&#034;500&#215;400&#034;)<\/p>\n<p>canvas &#061; tk.Canvas(root, width&#061;500, height&#061;400, bg&#061;&#034;white&#034;)<br \/>\ncanvas.pack()<\/p>\n<p>root.mainloop() <\/p>\n<h4 id=\"5.2%20%E5%9D%90%E6%A0%87%E7%B3%BB%E7%BB%9F%EF%BC%88%E5%85%B3%E9%94%AE%EF%BC%81%EF%BC%89\" style=\"background-color:transparent\">5.2 \u5750\u6807\u7cfb\u7edf&#xff08;\u5173\u952e&#xff01;&#xff09;<\/h4>\n<p>Canvas \u7684\u5750\u6807\u539f\u70b9\u5728\u5de6\u4e0a\u89d2&#xff0c;Y \u8f74\u5411\u4e0b\u589e\u957f\u2014\u2014\u548c\u6570\u5b66\u5750\u6807\u7cfb\u76f8\u53cd\u3002<\/p>\n<p>text<\/p>\n<p>(0,0) \u2192 X<br \/>\n  \u2193<br \/>\n  Y&#xff08;\u5411\u4e0b\u589e\u957f&#xff09; <\/p>\n<h4 id=\"5.3%20%E5%B8%B8%E7%94%A8%E7%BB%98%E5%9B%BE%E6%96%B9%E6%B3%95\" style=\"background-color:transparent\">5.3 \u5e38\u7528\u7ed8\u56fe\u65b9\u6cd5<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>create_line(x1,y1, x2,y2)<\/td>\n<td>\u753b\u76f4\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>create_rectangle(x1,y1, x2,y2)<\/td>\n<td>\u753b\u77e9\u5f62<\/td>\n<\/tr>\n<tr>\n<td>create_oval(x1,y1, x2,y2)<\/td>\n<td>\u753b\u5706\/\u692d\u5706<\/td>\n<\/tr>\n<tr>\n<td>create_polygon(x1,y1, x2,y2, &#8230;)<\/td>\n<td>\u753b\u591a\u8fb9\u5f62<\/td>\n<\/tr>\n<tr>\n<td>create_arc(x1,y1, x2,y2, start, extent)<\/td>\n<td>\u753b\u5706\u5f27<\/td>\n<\/tr>\n<tr>\n<td>create_text(x, y, text&#061;&#8230;)<\/td>\n<td>\u5199\u6587\u5b57<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f3af; \u4e00\u5f20\u56fe\u603b\u7ed3<\/p>\n<p>text<\/p>\n<p>              Tkinter \u5e94\u7528<br \/>\n \u2460 \u521b\u5efa\u7a97\u53e3&#xff1a;Tk() &#043; mainloop()<br \/>\n \u2461 \u6dfb\u52a0\u7ec4\u4ef6&#xff1a;Labe, Button, Entry, Text, Canvas<br \/>\n \u2462 \u5e03\u5c40\u7ba1\u7406&#xff1a;pack() \/ grid() \/ place()<br \/>\n \u2463 \u4e8b\u4ef6\u54cd\u5e94&#xff1a;command \/ bind()<br \/>\n \u2464 Canvas\u753b\u5e03&#xff1a;\u7ed8\u56fe &#043; \u52a8\u753b                  <\/p>\n<h3 id=\"%F0%9F%A7%81%20%E7%BB%93%E5%B0%BE\" style=\"background-color:transparent\">&#x1f9c1; \u7ed3\u5c3e<\/h3>\n<p>\u5230\u4eca\u5929\u4e3a\u6b62&#xff0c;\u4f60\u5df2\u7ecf\u5b66\u4f1a\u4e86&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u521b\u5efa\u7a97\u53e3\u00a0\u2014\u2014 \u8ba9 Python \u4e0d\u518d\u662f\u201c\u9ed1\u6846\u6846\u201d<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6dfb\u52a0\u7ec4\u4ef6\u00a0\u2014\u2014 Label\u3001Button\u3001Entry\u3001Text\u3001Canvas&#xff0c;\u754c\u9762\u7684\u57fa\u672c\u79ef\u6728<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5e03\u5c40\u7ba1\u7406\u00a0\u2014\u2014 pack\u3001grid\u3001place&#xff0c;\u628a\u4e1c\u897f\u6446\u597d\u770b<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e8b\u4ef6\u7ed1\u5b9a\u00a0\u2014\u2014 \u8ba9\u7528\u6237\u7684\u64cd\u4f5c\u89e6\u53d1\u7a0b\u5e8f\u54cd\u5e94<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Canvas \u753b\u5e03\u00a0\u2014\u2014 \u7ed8\u56fe\u548c\u7b80\u5355\u52a8\u753b<\/p>\n<p>Tkinter \u867d\u7136\u4e0d\u7b97\u201c\u989c\u503c\u62c5\u5f53\u201d&#xff0c;\u4f46\u80dc\u5728\u7b80\u5355\u3001\u591f\u7528\u3001\u4e0d\u7528\u6298\u817e\u73af\u5883\u3002\u4ee5\u540e\u4f60\u60f3\u5199\u4e2a\u5de5\u5177\u7ed9\u81ea\u5df1\u7528\u3001\u7ed9\u540c\u4e8b\u7528&#xff0c;\u4e0d\u7528\u518d\u5bf9\u7740\u547d\u4ee4\u884c\u89e3\u91ca\u4e86\u2014\u2014\u76f4\u63a5\u7529\u4e00\u4e2a\u00a0py\u00a0\u6587\u4ef6\u8fc7\u53bb&#xff0c;\u53cc\u51fb\u6253\u5f00\u5c31\u80fd\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u76ee\u5f55 &#x1f4d6; \u524d\u8a00 \u7b2c\u4e00\u7ae0&#xff1a;\u521d\u8bc6 Tkinter \u2014\u2014 \u7b2c\u4e00\u4e2a\u7a97\u53e3 1.1 \u68c0\u67e5 Tkinter \u662f\u5426\u5b89\u88c5 1.2 \u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a\u7a97\u53e3 \u7b2c\u4e8c\u7ae0&#xff1a;\u5e38\u7528\u7ec4\u4ef6 \u2014\u2014 \u642d\u5efa\u754c\u9762\u7684\u201c\u4e50\u9ad8\u79ef\u6728\u201d 2.1 Label \u2014\u2014 \u663e\u793a\u6587\u5b57\u6216\u56fe\u7247 2.2 Button \u2014\u2014 \u7528\u6237\u70b9\u51fb\u89e6\u53d1\u52a8\u4f5c \u5c40&#xff08;\u6700\u5e38\u7528&#xff09; 3.3 place() \u2014\u2014 \u7cbe\u786e\u201c\u50cf\u7d20\u7ea7\u201d\u5b9a\u4f4d \u7b2c\u4e09\u7ae0&#xff1a;\u5e03\u5c40\u7ba1\u7406 \u2014\u2014 \u600e\u4e48\u628a\u4e1c\u897f\u201c\u6446\u597d\u770b\u201d 3.1 pa<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10324,81,190],"topic":[],"class_list":["post-90662","post","type-post","status-publish","format-standard","hentry","category-server","tag-tkinte","tag-python","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/90662.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u76ee\u5f55 &#x1f4d6; \u524d\u8a00 \u7b2c\u4e00\u7ae0&#xff1a;\u521d\u8bc6 Tkinter \u2014\u2014 \u7b2c\u4e00\u4e2a\u7a97\u53e3 1.1 \u68c0\u67e5 Tkinter \u662f\u5426\u5b89\u88c5 1.2 \u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a\u7a97\u53e3 \u7b2c\u4e8c\u7ae0&#xff1a;\u5e38\u7528\u7ec4\u4ef6 \u2014\u2014 \u642d\u5efa\u754c\u9762\u7684\u201c\u4e50\u9ad8\u79ef\u6728\u201d 2.1 Label \u2014\u2014 \u663e\u793a\u6587\u5b57\u6216\u56fe\u7247 2.2 Button \u2014\u2014 \u7528\u6237\u70b9\u51fb\u89e6\u53d1\u52a8\u4f5c \u5c40&#xff08;\u6700\u5e38\u7528&#xff09; 3.3 place() \u2014\u2014 \u7cbe\u786e\u201c\u50cf\u7d20\u7ea7\u201d\u5b9a\u4f4d \u7b2c\u4e09\u7ae0&#xff1a;\u5e03\u5c40\u7ba1\u7406 \u2014\u2014 \u600e\u4e48\u628a\u4e1c\u897f\u201c\u6446\u597d\u770b\u201d 3.1 pa\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/90662.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-05T11:00:42+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90662.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/90662.html\",\"name\":\"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-05T11:00:42+00:00\",\"dateModified\":\"2026-08-05T11:00:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/90662.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/90662.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90662.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/90662.html","og_locale":"zh_CN","og_type":"article","og_title":"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u76ee\u5f55 &#x1f4d6; \u524d\u8a00 \u7b2c\u4e00\u7ae0&#xff1a;\u521d\u8bc6 Tkinter \u2014\u2014 \u7b2c\u4e00\u4e2a\u7a97\u53e3 1.1 \u68c0\u67e5 Tkinter \u662f\u5426\u5b89\u88c5 1.2 \u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a\u7a97\u53e3 \u7b2c\u4e8c\u7ae0&#xff1a;\u5e38\u7528\u7ec4\u4ef6 \u2014\u2014 \u642d\u5efa\u754c\u9762\u7684\u201c\u4e50\u9ad8\u79ef\u6728\u201d 2.1 Label \u2014\u2014 \u663e\u793a\u6587\u5b57\u6216\u56fe\u7247 2.2 Button \u2014\u2014 \u7528\u6237\u70b9\u51fb\u89e6\u53d1\u52a8\u4f5c \u5c40&#xff08;\u6700\u5e38\u7528&#xff09; 3.3 place() \u2014\u2014 \u7cbe\u786e\u201c\u50cf\u7d20\u7ea7\u201d\u5b9a\u4f4d \u7b2c\u4e09\u7ae0&#xff1a;\u5e03\u5c40\u7ba1\u7406 \u2014\u2014 \u600e\u4e48\u628a\u4e1c\u897f\u201c\u6446\u597d\u770b\u201d 3.1 pa","og_url":"https:\/\/www.wsisp.com\/helps\/90662.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-05T11:00:42+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/90662.html","url":"https:\/\/www.wsisp.com\/helps\/90662.html","name":"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-05T11:00:42+00:00","dateModified":"2026-08-05T11:00:42+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/90662.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/90662.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/90662.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python Tkinter\uff1a\u7ed9\u4ee3\u7801\u88c5\u4e2a\u201c\u53ef\u89c6\u5316\u5916\u58f3\u201d"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=90662"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90662\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=90662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=90662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=90662"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=90662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}