Title: Openai/6971ad15-bc24-8001-895c-a3da27712d3a - freem URL Source: https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=595947&title=Openai%2F6971ad15-bc24-8001-895c-a3da27712d3a Markdown Content: (diff) ← Older revision | Latest revision (diff) | Newer revision → (diff) _This conversation was exported from ChatGPT_[[1]](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=595947&title=Openai%2F6971ad15-bc24-8001-895c-a3da27712d3a#cite_note-1) ## gpt-5-mini[edit](https://freemwiki.com/index.php?title=Openai/6971ad15-bc24-8001-895c-a3da27712d3a&action=edit§ion=1 "Edit section: gpt-5-mini") ### User: 用 python 寫桌面應用,顯示月曆[edit](https://freemwiki.com/index.php?title=Openai/6971ad15-bc24-8001-895c-a3da27712d3a&action=edit§ion=2 "Edit section: User: 用 python 寫桌面應用,顯示月曆") 用 python 寫桌面應用,顯示月曆 ### Assistant: 明白了,你想用 Python 做一個桌面應用來顯示月曆。我可以給你一個完整示例,使用 Tkinter(Python 內建的 GUI 庫)結合 calendar 模組來生成月曆。這個應用可以選擇年份和月份,並在窗口中顯示對應的月曆。[edit](https://freemwiki.com/index.php?title=Openai/6971ad15-bc24-8001-895c-a3da27712d3a&action=edit§ion=3 "Edit section: Assistant: 明白了,你想用 Python 做一個桌面應用來顯示月曆。我可以給你一個完整示例,使用 Tkinter(Python 內建的 GUI 庫)結合 calendar 模組來生成月曆。這個應用可以選擇年份和月份,並在窗口中顯示對應的月曆。") 明白了,你想用 Python 做一個桌面應用來顯示月曆。我可以給你一個完整示例,使用 Tkinter(Python 內建的 GUI 庫)結合 calendar 模組來生成月曆。這個應用可以選擇年份和月份,並在窗口中顯示對應的月曆。 下面是一個完整範例: import tkinter as tk from tkinter import ttk import calendar def show_calendar(): year = int(year_entry.get()) month = int(month_combo.get()) # 清空之前的月曆 cal_text.delete('1.0', tk.END) # 生成月曆 cal = calendar.month(year, month) cal_text.insert(tk.END, cal) === 建立主窗口 === root = tk.Tk() root.title("月曆顯示器") root.geometry("400x400") === 年份輸入 === tk.Label(root, text="年份:").pack(pady=5) year_entry = tk.Entry(root) year_entry.pack() year_entry.insert(0, "2026") # 預設年份 === 月份選擇 === tk.Label(root, text="月份:").pack(pady=5) month_combo = ttk.Combobox(root, values=list(range(1, 13))) month_combo.pack() month_combo.current(0) # 預設 1 月 === 顯示月曆按鈕 === tk.Button(root, text="顯示月曆", command=show_calendar).pack(pady=10) === 月曆文字框 === cal_text = tk.Text(root, width=30, height=10, font=("Courier", 12)) cal_text.pack(pady=10) root.mainloop() ##### 功能說明:[edit](https://freemwiki.com/index.php?title=Openai/6971ad15-bc24-8001-895c-a3da27712d3a&action=edit§ion=4 "Edit section: 功能說明:") 1. 使用 Entry 輸入年份。 2. 使用 Combobox 選擇月份。 3. 按下按鈕就會生成對應月份的文字月曆,顯示在 Text 小工具中。 4. 字體使用等寬字體 "Courier",這樣月曆排列會整齊。 如果你願意,我可以幫你升級這個版本,做成 漂亮的圖形化月曆(像 Windows 日曆那樣,每天一格,點擊還能做標記),而不是純文字版。 你希望我做這個升級嗎? ## References[edit](https://freemwiki.com/index.php?title=Openai/6971ad15-bc24-8001-895c-a3da27712d3a&action=edit§ion=5 "Edit section: References") 1. [↑](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=595947&title=Openai%2F6971ad15-bc24-8001-895c-a3da27712d3a#cite_ref-1)["Python 月曆桌面應用"](https://chatgpt.com/share/6971ad15-bc24-8001-895c-a3da27712d3a). ChatGPT. Retrieved 2026-01-23.