我如何更改 tkcalendar 中天数(数字)的位置

How can i change the position of the days(number) in tkcalendar

我希望将每个方块中的天数从中间移到左上角。我已经阅读了 tkcalendar 的文档,但我无法在网上找到任何东西。我无法尝试任何事情,因为我还没有看到任何这样做的例子。如果可能,有人可以帮我解决这个问题吗?

python 版本 = 2.7.16

系统 = macOS Mojave 10.14.6

编码水平=菜鸟-初学者

感谢您的帮助和时间。

没有更改天数位置的选项。因此,有必要深入widget的源码来做。日期只是标签,因此可以通过将 anchor 选项设置为 "nw" 来获得所需的位置。它们存储在名为 ._calendar 的列表列表中(每周一个列表):

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()