customtkinter 的大小似乎是普通 tkinter 的 1.5 倍

问题描述 投票:0回答:1

问题:我尝试用 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 倍。

有人知道这种行为的原因吗?

python user-interface tkinter scale customtkinter
1个回答
0
投票

诅咒你的Windows 10!我的疏忽令人尴尬。

my settings

要解决这些问题,请将显示设置中的“缩放和布局”选项更改为 100% 而不是 150%。

© www.soinside.com 2019 - 2024. All rights reserved.