Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/6971ad15-bc24-8001-895c-a3da27712d3a
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{DISPLAYTITLE:Python 月曆桌面應用}} ''This conversation was exported from ChatGPT''<ref>{{cite web|title=Python 月曆桌面應用|url=https://chatgpt.com/share/6971ad15-bc24-8001-895c-a3da27712d3a|publisher=ChatGPT|access-date=2026-01-23}}</ref> == gpt-5-mini == === User: 用 python 寫桌面應用,顯示月曆 === 用 python 寫桌面應用,顯示月曆 === Assistant: 明白了,你想用 Python 做一個桌面應用來顯示月曆。我可以給你一個完整示例,使用 Tkinter(Python 內建的 GUI 庫)結合 calendar 模組來生成月曆。這個應用可以選擇年份和月份,並在窗口中顯示對應的月曆。 === 明白了,你想用 Python 做一個桌面應用來顯示月曆。我可以給你一個完整示例,使用 Tkinter(Python 內建的 GUI 庫)結合 calendar 模組來生成月曆。這個應用可以選擇年份和月份,並在窗口中顯示對應的月曆。 下面是一個完整範例: <syntaxhighlight lang="python">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() </syntaxhighlight> ===== 功能說明: ===== # 使用 Entry 輸入年份。 # 使用 Combobox 選擇月份。 # 按下按鈕就會生成對應月份的文字月曆,顯示在 Text 小工具中。 # 字體使用等寬字體 "Courier",這樣月曆排列會整齊。 如果你願意,我可以幫你升級這個版本,做成 漂亮的圖形化月曆(像 Windows 日曆那樣,每天一格,點擊還能做標記),而不是純文字版。 你希望我做這個升級嗎? == References == <references /> [[Category:ChatGPT Shares]] [[Category:openai]]
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Cite web
(
edit
)
Module:Citation/CS1
(
edit
)
Module:Citation/CS1/COinS
(
edit
)
Module:Citation/CS1/Configuration
(
edit
)
Module:Citation/CS1/Date validation
(
edit
)
Module:Citation/CS1/Identifiers
(
edit
)
Module:Citation/CS1/Utilities
(
edit
)
Module:Citation/CS1/Whitelist
(
edit
)
Module:Citation/CS1/styles.css
(
edit
)