问题:我尝试用 customtkinter 制作一个 400x400 的窗口:
import customtkinter as ctk
# this function helps me verify the size of the window. I can click around and see the coordinates
def printPosition(event):
print(event.x, event.y)
root = ctk.CTk()
root.geometry("%dx%d%+d%+d"%(400, 400, 0, 0))
root.bind("<ButtonPress-1>", printPosition)
root.mainloop()
一切似乎都很好,除了当我点击我希望看到的窗口的右下角时 “400、400”打印出来。相反,我看到“600, 600”。我也尝试过使用其他尺寸的窗户,尺寸总是达到我想要的尺寸的 1.5 倍。
为了确保我不仅仅是疯了,我在常规 tkinter 中尝试了相同的程序,正如您所期望的那样,右下角是“400, 400”:
import tkinter as tk
def printPosition(event):
print(event.x, event.y)
root = tk.Tk()
root.geometry("%dx%d%+d%+d"%(400, 400, 0, 0))
root.bind("<ButtonPress-1>", printPosition)
root.mainloop()
如果有帮助的话,我也注意到 customtkinter 框架也有同样的现象,它们的尺寸也是 1.5 倍。
有人知道这种行为的原因吗?