{"id":227,"date":"2024-12-17T23:23:02","date_gmt":"2024-12-17T15:23:02","guid":{"rendered":"https:\/\/hello.sunnyblog.fun:2087\/sakurairo\/?p=227"},"modified":"2024-12-19T17:16:43","modified_gmt":"2024-12-19T09:16:43","slug":"shuduxiaoyouxi","status":"publish","type":"post","link":"https:\/\/hello.waitrain.fun\/index.php\/2024\/12\/17\/shuduxiaoyouxi\/","title":{"rendered":"\u6570\u72ec\u5c0f\u6e38\u620f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4eca\u5929\u6211\u59b9\u7a81\u7136\u62ff\u4e86\u4e2a\u9898\u76ee\u7ed9\u6211\u5199\uff0c\u4e0d\u96be\uff0c\u4f46\u633a\u6709\u610f\u601d\u7684<\/p>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\" style=\"grid-template-columns:65% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/hello.sunnyblog.fun:2087\/sakurairo\/wp-content\/uploads\/2024\/12\/1734446685-IMG_20241217_224310-1024x768.jpg\" alt=\"\" class=\"wp-image-229 size-full\" srcset=\"https:\/\/hello.waitrain.fun\/wp-content\/uploads\/2024\/12\/1734446685-IMG_20241217_224310-1024x768.jpg 1024w, https:\/\/hello.waitrain.fun\/wp-content\/uploads\/2024\/12\/1734446685-IMG_20241217_224310-300x225.jpg 300w, https:\/\/hello.waitrain.fun\/wp-content\/uploads\/2024\/12\/1734446685-IMG_20241217_224310-768x576.jpg 768w, https:\/\/hello.waitrain.fun\/wp-content\/uploads\/2024\/12\/1734446685-IMG_20241217_224310-1536x1152.jpg 1536w, https:\/\/hello.waitrain.fun\/wp-content\/uploads\/2024\/12\/1734446685-IMG_20241217_224310-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">\u7ecf\u5178\u7684\u6570\u72ec\u6e38\u620f<\/p>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u7a81\u53d1\u5947\u60f3\u5c1d\u8bd5\u5199\u4e86\u4e2apy\u811a\u672c\uff0c\u8c03\u7528gui\u5e93\u5b9e\u73b0\u9762\u677f\u529f\u80fd\uff0c\u6c42\u6570\u72ec\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import tkinter as tk\nfrom tkinter import messagebox\n \ndef is_valid(board, row, col, num):\n    for i in range(9):\n        if board&#91;row]&#91;i] == num:\n            return False\n    for i in range(9):\n        if board&#91;i]&#91;col] == num:\n            return False\n    start_row = (row \/\/ 3) * 3\n    start_col = (col \/\/ 3) * 3\n    for i in range(3):\n        for j in range(3):\n            if board&#91;start_row + i]&#91;start_col + j] == num:\n                return False\n    return True\n \ndef solve_sudoku(board):\n    for row in range(9):\n        for col in range(9):\n            if board&#91;row]&#91;col] == '*':\n                for num in range(1, 10):\n                    num = str(num)\n                    if is_valid(board, row, col, num):\n                        board&#91;row]&#91;col] = num\n                        if solve_sudoku(board):\n                            return True\n                        board&#91;row]&#91;col] = '*'\n                return False\n    return True\n \ndef get_board_from_input(entries):\n    board = &#91;]\n    for row in range(9):\n        board_row = &#91;]\n        for col in range(9):\n            value = entries&#91;row]&#91;col].get().strip()\n            if value == '' or value == '*':\n                board_row.append('*')\n            else:\n                board_row.append(value)\n        board.append(board_row)\n    return board\n \ndef show_result(board):\n    result = '\\n'.join(&#91;' '.join(row) for row in board])\n    messagebox.showinfo(\"\u6570\u72ec\u89e3\", f\"\u89e3\u7b54\u7ed3\u679c\uff1a\\n{result}\")\n \ndef on_submit(entries):\n    board = get_board_from_input(entries)\n    solve_sudoku(board)\n    show_result(board)\n \ndef create_gui():\n    window = tk.Tk()\n    window.title(\"\u6570\u72ec\u89e3\u7b54\u5668\")\n \n    entries = &#91;]\n    for row in range(9):\n        row_entries = &#91;]\n        for col in range(9):\n            entry = tk.Entry(window, width=5, font=(\"Arial\", 14), justify='center')\n            entry.grid(row=row, column=col, padx=5, pady=5)\n            row_entries.append(entry)\n        entries.append(row_entries)\n \n    default_board = &#91;\n        &#91;'8', ' ', '6', ' ', ' ', '3', ' ', '9', ' '],\n        &#91;' ', '4', ' ', ' ', '1', ' ', ' ', '6', '8'],\n        &#91;'2', ' ', ' ', '8', '7', ' ', ' ', ' ', '5'],\n        &#91;'1', ' ', '8', ' ', ' ', '5', ' ', '2', ' '],\n        &#91;' ', '3', ' ', '1', ' ', ' ', ' ', '5', ' '],\n        &#91;'7', ' ', '5', ' ', '3', ' ', '9', ' ', ' '],\n        &#91;' ', '2', '1', ' ', ' ', '7', ' ', '4', ' '],\n        &#91;'6', ' ', ' ', ' ', '2', ' ', '8', ' ', ' '],\n        &#91;' ', '8', '7', '6', ' ', '4', ' ', ' ', '3']\n    ]\n \n    for i in range(9):\n        for j in range(9):\n            entries&#91;i]&#91;j].insert(0, default_board&#91;i]&#91;j])\n \n    submit_button = tk.Button(window, text=\"\u786e\u5b9a\", font=(\"Arial\", 14), command=lambda: on_submit(entries))\n    submit_button.grid(row=9, column=4, columnspan=2, pady=10)\n \n    window.mainloop()\n \ncreate_gui()\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">gui\u6837\u5f0f\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"413\" src=\"https:\/\/hello.sunnyblog.fun:2087\/sakurairo\/wp-content\/uploads\/2024\/12\/1734452358-\u5c4f\u5e55\u622a\u56fe-2024-12-18-001435.png\" alt=\"\" class=\"wp-image-242\" srcset=\"https:\/\/hello.waitrain.fun\/wp-content\/uploads\/2024\/12\/1734452358-\u5c4f\u5e55\u622a\u56fe-2024-12-18-001435.png 624w, https:\/\/hello.waitrain.fun\/wp-content\/uploads\/2024\/12\/1734452358-\u5c4f\u5e55\u622a\u56fe-2024-12-18-001435-300x199.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee5\u4e0b\u4e3a\u4ee3\u7801\u8be6\u89e3\uff1a<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u5bfc\u5165\u5e93<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>import tkinter as tk\nfrom tkinter import messagebox\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>tkinter<\/code> \u662f Python \u6807\u51c6\u5e93\u4e2d\u7684\u4e00\u4e2a GUI \u5e93\uff0c\u7528\u4e8e\u521b\u5efa\u56fe\u5f62\u754c\u9762\u3002\u8fd9\u91cc\u5bfc\u5165 <code>tkinter<\/code> \u548c\u5176\u4e2d\u7684 <code>messagebox<\/code> \u6a21\u5757\uff0c\u540e\u8005\u7528\u6765\u663e\u793a\u5f39\u51fa\u5f0f\u6d88\u606f\u6846\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u68c0\u67e5\u6570\u72ec\u662f\u5426\u5408\u6cd5<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def is_valid(board, row, col, num):\n    for i in range(9):\n        if board&#91;row]&#91;i] == num:\n            return False\n    for i in range(9):\n        if board&#91;i]&#91;col] == num:\n            return False\n    start_row = (row \/\/ 3) * 3\n    start_col = (col \/\/ 3) * 3\n    for i in range(3):\n        for j in range(3):\n            if board&#91;start_row + i]&#91;start_col + j] == num:\n                return False\n    return True\n<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u51fd\u6570\u7528\u6765\u68c0\u67e5\u5f53\u524d\u6570\u72ec\u68cb\u76d8\u4e0a\u653e\u7f6e\u7684\u6570\u5b57\u662f\u5426\u7b26\u5408\u6570\u72ec\u89c4\u5219\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u72ec\u89c4\u5219\u8981\u6c42\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u540c\u4e00\u884c\u4e0d\u80fd\u6709\u91cd\u590d\u7684\u6570\u5b57\u3002<\/li>\n\n\n\n<li>\u540c\u4e00\u5217\u4e0d\u80fd\u6709\u91cd\u590d\u7684\u6570\u5b57\u3002<\/li>\n\n\n\n<li>\u540c\u4e00\u4e2a 3x3 \u7684\u5c0f\u5bab\u683c\u91cc\u4e0d\u80fd\u6709\u91cd\u590d\u7684\u6570\u5b57\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u6c42\u89e3\u6570\u72ec\uff08\u56de\u6eaf\u6cd5\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def solve_sudoku(board):\n    for row in range(9):\n        for col in range(9):\n            if board&#91;row]&#91;col] == '*':\n                for num in range(1, 10):\n                    num = str(num)\n                    if is_valid(board, row, col, num):\n                        board&#91;row]&#91;col] = num\n                        if solve_sudoku(board):\n                            return True\n                        board&#91;row]&#91;col] = '*'\n                return False\n    return True\n<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u56de\u6eaf\u6cd5<\/strong>\u662f\u7528\u6765\u6c42\u89e3\u6570\u72ec\u7684\u5e38\u89c1\u7b97\u6cd5\uff0c\u5f53\u7136\uff0c\u4f60\u4e5f\u57fa\u672c\u4e0a\u53ef\u4ee5\u628a\u5b83\u7406\u89e3\u4e3a\u7a77\u4e3e\u6cd5<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b83\u7684\u57fa\u672c\u601d\u8def\u662f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4ece\u6570\u72ec\u7684\u6bcf\u4e2a\u7a7a\u683c\uff08<code>*<\/code>\uff09\u5f00\u59cb\uff0c\u5c1d\u8bd5\u586b\u5165\u4e00\u4e2a\u5408\u6cd5\u7684\u6570\u5b57\uff081 \u5230 9\uff09\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u586b\u5165\u7684\u6570\u5b57\u5408\u6cd5\uff08\u901a\u8fc7 <code>is_valid<\/code> \u51fd\u6570\u9a8c\u8bc1\uff09\uff0c\u7ee7\u7eed\u9012\u5f52\u586b\u5145\u4e0b\u4e00\u4e2a\u7a7a\u683c\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u6240\u6709\u7a7a\u683c\u90fd\u6210\u529f\u586b\u5145\u5b8c\u6bd5\uff0c\u5219\u8fd4\u56de <code>True<\/code>\uff0c\u8868\u793a\u627e\u5230\u4e86\u4e00\u4e2a\u89e3\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u67d0\u4e2a\u6570\u5b57\u4e0d\u5408\u6cd5\uff0c\u56de\u6eaf\u5230\u4e0a\u4e00\u6b65\uff0c\u5c1d\u8bd5\u5176\u4ed6\u53ef\u80fd\u7684\u6570\u5b57\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u6ca1\u6709\u6570\u5b57\u53ef\u586b\uff0c\u5219\u8fd4\u56de <code>False<\/code>\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u975e\u5e38\u7684\u7b80\u5355\u5bf9\u5427\uff0c\u5c31\u662f\u7a77\u4e3e\uff0c\u7b80\u5355\u66b4\u529b~<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u68cb\u76d8\u6570\u636e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def get_board_from_input(entries):\n    board = &#91;]\n    for row in range(9):\n        board_row = &#91;]\n        for col in range(9):\n            value = entries&#91;row]&#91;col].get().strip()\n            if value == '' or value == '*':\n                board_row.append('*')\n            else:\n                board_row.append(value)\n        board.append(board_row)\n    return board\n<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u51fd\u6570\u7528\u4e8e\u4ece GUI \u754c\u9762\u7684\u8f93\u5165\u6846\u4e2d\u83b7\u53d6\u6570\u72ec\u68cb\u76d8\u7684\u503c\u3002\u6bcf\u4e2a\u8f93\u5165\u6846\u7684\u503c\u901a\u8fc7 <code>.get()<\/code> \u65b9\u6cd5\u83b7\u5f97\uff0c\u5e76\u53bb\u6389\u4e24\u7aef\u7684\u7a7a\u683c\uff08<code>.strip()<\/code>\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4ee3\u7801\u903b\u8f91\u89e3\u91ca\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u7528\u6237\u6ca1\u6709\u8f93\u5165\u503c\uff0c\u6216\u8f93\u5165\u7684\u662f <code>*<\/code>\uff0c\u5c31\u5c06\u8fd9\u4e2a\u4f4d\u7f6e\u6807\u8bb0\u4e3a\u7a7a\u683c\uff08<code>*<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u7528\u6237\u8f93\u5165\u7684\u662f\u6570\u5b57\uff0c\u5c31\u5c06\u8be5\u6570\u5b57\u4f5c\u4e3a\u5f53\u524d\u683c\u5b50\u7684\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\uff08\u7528\u6237\u4f7f\u7528\u201d*\u201c\u6765\u586b\u5199\u5230\u7a7a\u7f3a\u4f4d\u4f5c\u4e3a\u6807\u8bb0\uff0c\u4ee5\u514d\u770b\u9519\u770b\u6389\uff09<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u663e\u793a\u89e3\u7b54\u7ed3\u679c<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def show_result(board):\n    result = '\\n'.join(&#91;' '.join(row) for row in board])\n    messagebox.showinfo(\"\u6570\u72ec\u89e3\", f\"\u89e3\u7b54\u7ed3\u679c\uff1a\\n{result}\")\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>show_result<\/code> \u51fd\u6570\u7528\u4e8e\u5c06\u6570\u72ec\u7684\u89e3\u7b54\u901a\u8fc7\u5f39\u7a97\u7684\u65b9\u5f0f\u5c55\u793a\u7ed9\u7528\u6237\u3002<\/li>\n\n\n\n<li>\u8be5\u51fd\u6570\u5c06 <code>board<\/code>\uff08\u6570\u72ec\u68cb\u76d8\uff09\u4e2d\u7684\u6bcf\u4e00\u884c\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\uff0c\u5e76\u7528\u6362\u884c\u7b26\u8fde\u63a5\u5404\u884c\uff0c\u5f62\u6210\u6700\u7ec8\u7684\u5b57\u7b26\u4e32 <code>result<\/code>\u3002<\/li>\n\n\n\n<li>\u7136\u540e\u901a\u8fc7 <code>messagebox.showinfo<\/code> \u663e\u793a\u5f39\u51fa\u7a97\u53e3\uff0c\u544a\u8bc9\u7528\u6237\u89e3\u7b54\u7ed3\u679c\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u5904\u7406\u7528\u6237\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\u7684\u4e8b\u4ef6<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def on_submit(entries):\n    board = get_board_from_input(entries)\n    solve_sudoku(board)\n    show_result(board)\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>on_submit<\/code> \u51fd\u6570\u4f1a\u5728\u7528\u6237\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\u65f6\u89e6\u53d1\u3002<\/li>\n\n\n\n<li>\u9996\u5148\u8c03\u7528 <code>get_board_from_input<\/code> \u4ece\u754c\u9762\u8f93\u5165\u6846\u4e2d\u83b7\u53d6\u6570\u72ec\u68cb\u76d8\u6570\u636e\u3002<\/li>\n\n\n\n<li>\u7136\u540e\u8c03\u7528 <code>solve_sudoku<\/code> \u6765\u6c42\u89e3\u6570\u72ec\u3002<\/li>\n\n\n\n<li>\u6700\u540e\uff0c\u8c03\u7528 <code>show_result<\/code> \u663e\u793a\u89e3\u7b54\u7ed3\u679c\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">7. \u521b\u5efa GUI \u754c\u9762<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def create_gui():\n    window = tk.Tk()\n    window.title(\"\u6570\u72ec\u89e3\u7b54\u5668\")\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>create_gui<\/code> \u51fd\u6570\u521b\u5efa\u4e86\u4e00\u4e2a <code>Tk<\/code> \u7a97\u53e3\u5b9e\u4f8b\uff0c\u4f5c\u4e3a\u6570\u72ec\u6e38\u620f\u7684\u4e3b\u754c\u9762\u3002<\/li>\n\n\n\n<li>\u7a97\u53e3\u6807\u9898\u8bbe\u7f6e\u4e3a\u201c\u6570\u72ec\u89e3\u7b54\u5668\u201d\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">8. \u521b\u5efa\u8f93\u5165\u6846\u548c\u201c\u786e\u5b9a\u201d\u6309\u94ae<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>entries = &#91;]\nfor row in range(9):\n    row_entries = &#91;]\n    for col in range(9):\n        entry = tk.Entry(window, width=5, font=(\"Arial\", 14), justify='center')\n        entry.grid(row=row, column=col, padx=5, pady=5)\n        row_entries.append(entry)\n    entries.append(row_entries)\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8fd9\u6bb5\u4ee3\u7801\u521b\u5efa\u4e86\u4e00\u4e2a 9x9 \u7684\u8f93\u5165\u6846\u7f51\u683c\u3002\u6bcf\u4e2a\u8f93\u5165\u6846\u7528\u4e8e\u8f93\u5165\u6570\u72ec\u68cb\u76d8\u4e2d\u7684\u6570\u5b57\u3002<\/li>\n\n\n\n<li><code>tk.Entry<\/code> \u521b\u5efa\u4e86\u4e00\u4e2a\u5355\u72ec\u7684\u8f93\u5165\u6846\uff0c\u8bbe\u7f6e\u5bbd\u5ea6\u4e3a 5\uff0c\u5b57\u4f53\u4e3a Arial\uff0c\u5b57\u53f7\u4e3a 14\uff0c\u5e76\u4e14\u6587\u5b57\u5c45\u4e2d\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 <code>grid<\/code> \u5e03\u5c40\u65b9\u6cd5\u5c06\u8f93\u5165\u6846\u653e\u7f6e\u5728\u7a97\u53e3\u4e2d\uff0c<code>padx<\/code> \u548c <code>pady<\/code> \u63a7\u5236\u8f93\u5165\u6846\u4e4b\u95f4\u7684\u95f4\u8ddd\u3002<\/li>\n\n\n\n<li><code>entries<\/code> \u662f\u4e00\u4e2a\u4e8c\u7ef4\u5217\u8868\uff0c\u7528\u6765\u5b58\u50a8\u6bcf\u4e2a\u8f93\u5165\u6846\u7684\u5f15\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">9. \u586b\u5145\u9ed8\u8ba4\u6570\u72ec\u68cb\u76d8<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>default_board = &#91;\n    &#91;'8', ' ', '6', ' ', ' ', '3', ' ', '9', ' '],\n    &#91;' ', '4', ' ', ' ', '1', ' ', ' ', '6', '8'],\n    &#91;'2', ' ', ' ', '8', '7', ' ', ' ', ' ', '5'],\n    &#91;'1', ' ', '8', ' ', ' ', '5', ' ', '2', ' '],\n    &#91;' ', '3', ' ', '1', ' ', ' ', ' ', '5', ' '],\n    &#91;'7', ' ', '5', ' ', '3', ' ', '9', ' ', ' '],\n    &#91;' ', '2', '1', ' ', ' ', '7', ' ', '4', ' '],\n    &#91;'6', ' ', ' ', ' ', '2', ' ', '8', ' ', ' '],\n    &#91;' ', '8', '7', '6', ' ', '4', ' ', ' ', '3']\n]\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>default_board<\/code> \u662f\u4e00\u4e2a\u9884\u8bbe\u7684\u6570\u72ec\u68cb\u76d8\uff0c\u7528\u6237\u53ef\u4ee5\u4fee\u6539\u8fd9\u4e9b\u7a7a\u683c\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">10. \u786e\u5b9a\u6309\u94ae<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>submit_button = tk.Button(window, text=\"\u786e\u5b9a\", font=(\"Arial\", 14), command=lambda: on_submit(entries))\nsubmit_button.grid(row=9, column=4, columnspan=2, pady=10)\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u521b\u5efa\u4e86\u4e00\u4e2a\u201c\u786e\u5b9a\u201d\u6309\u94ae\uff0c\u70b9\u51fb\u65f6\u8c03\u7528 <code>on_submit(entries)<\/code> \u51fd\u6570\u3002<\/li>\n\n\n\n<li><code>command<\/code> \u53c2\u6570\u5c06\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\u4e0e <code>on_submit<\/code> \u51fd\u6570\u7ed1\u5b9a\u8d77\u6765\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">11. \u542f\u52a8 GUI \u754c\u9762<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>window.mainloop()\n<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>window.mainloop()<\/code> \u542f\u52a8\u4e86 <code>tkinter<\/code> \u7684\u4e8b\u4ef6\u5faa\u73af\uff0c\u663e\u793a\u7a97\u53e3\u5e76\u7b49\u5f85\u7528\u6237\u4e0e\u754c\u9762\u4ea4\u4e92\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">OK\uff0c\u5c31\u8fd9\uff0cover\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6211\u59b9\u7a81\u7136\u62ff\u4e86\u4e2a\u9898\u76ee\u7ed9\u6211\u5199\uff0c\u4e0d\u96be\uff0c\u4f46\u633a\u6709\u610f\u601d\u7684 \u7ecf\u5178\u7684\u6570\u72ec\u6e38\u620f \u7a81\u53d1\u5947\u60f3\u5c1d\u8bd5\u5199\u4e86\u4e2apy\u811a\u672c\uff0c\u8c03\u7528gui\u5e93\u5b9e\u73b0\u9762\u677f\u529f\u80fd\uff0c\u6c42\u6570\u72ec\uff1a  &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[12,11],"tags":[13,14],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-12","category-11","tag-python","tag-14"],"_links":{"self":[{"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/comments?post=227"}],"version-history":[{"count":7,"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/posts\/227\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hello.waitrain.fun\/index.php\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}