Python 如何更改tkcalendar中天数的位置
我想把每个正方形的天数从中间移到左上角。我已经阅读了tkcalendar的文档,但在网上找不到任何内容。我还没有尝试过任何东西,因为我还没有看到任何这样做的例子。如果可能的话,有人能帮我吗 python版本=2.7.16 系统=macOS Mojave 10.14.6 编码级别=noob-初学者Python 如何更改tkcalendar中天数的位置,python,tkcalendar,Python,Tkcalendar,我想把每个正方形的天数从中间移到左上角。我已经阅读了tkcalendar的文档,但在网上找不到任何内容。我还没有尝试过任何东西,因为我还没有看到任何这样做的例子。如果可能的话,有人能帮我吗 python版本=2.7.16 系统=macOS Mojave 10.14.6 编码级别=noob-初学者 感谢您的帮助和时间。无法更改日数的位置。因此,有必要深入研究小部件的源代码来实现这一点。日期只是标签,因此可以通过将其锚定选项设置为“nw”来获得所需的位置。它们存储在名为\u calendar的列表
感谢您的帮助和时间。无法更改日数的位置。因此,有必要深入研究小部件的源代码来实现这一点。日期只是标签,因此可以通过将其
锚定
选项设置为“nw”
来获得所需的位置。它们存储在名为\u calendar
的列表中(每周一个列表):
截至2020年,Python 2.7已失去支持。为什么不更新到3.9呢?我有一个文件夹,上面写着Python3.9(我最近在删除了所有旧的Python安装后下载了它),但Terminal告诉我我的Python版本是2.7。我可能做错了什么,但我想这是下一次的问题@酷云
import tkinter as tk
from tkcalendar import Calendar
class MyCalendar(Calendar):
def __init__(self, master, **kw):
Calendar.__init__(self, master, **kw)
for row in self._calendar:
for label in row:
label['anchor'] = "nw"
# # uncomment this block to align left weekday names
# for label in self._week_days:
# label['anchor'] = "w"
root = tk.Tk()
cal = MyCalendar(root, showweeknumbers=False)
cal.pack(fill='both', expand=True)
root.geometry("400x300")
root.mainloop()