为什么ramy winfo\u screenmmwidth()和winfo\u screenmmheight()得到了一些奇怪的数字?

我必须把我的宽度乘以3.78,把高度乘以3.779

from tkinter import *
from PIL import ImageTk,Image


root = Tk()
root.title("My Program")

# Designate the height and width of our app
app_width = 500
app_height = 500

screen_width = root.winfo_screenmmwidth()
screen_height = root.winfo_screenmmheight()


dpi = root.winfo_fpixels('1i')

real_width = int(screen_width * 3.78)
real_height = int(screen_height * 3.779)

root.geometry(f"{app_width}x{app_height}+{1000}+{200}")

mylbl = Label(root,text=f"{real_width}x{real_height}")
mylbl.pack()





root.mainloop()

当我不做奇怪的乘法运算时,得到的是508x286,而不是1920x1080

是什么原因造成的?

推荐答案

为了让它工作,你必须改变

winfo_screenmmwidth()

进入:

winfo_screenwidth()

高度也是一样.否则,其测量单位为毫米.

P、 对 comments 中的人说

Python相关问答推荐

按列分区,按另一列排序

Telethon加入私有频道

Python中绕y轴曲线的旋转

将pandas导出到CSV数据,但在此之前,将日期按最小到最大排序

python panda ExcelWriter切换动态公式到数组公式

在Admin中显示从ManyToMany通过模型的筛选结果

用SymPy在Python中求解指数函数

计算空值

如何求相邻对序列中元素 Select 的最小代价

如何在FastAPI中替换Pydantic的constr,以便在BaseModel之外使用?'

Pandas 数据帧中的枚举,不能在枚举列上执行GROUP BY吗?

Regex用于匹配Python中逗号分隔的AWS区域

Pythonquests.get(Url)返回Colab中的空内容

如何在python tkinter中绑定键盘上的另一个回车?

在一个数据帧中,我如何才能发现每个行号是否出现在一列列表中?

FileNotFoundError:[WinError 2]系统找不到指定的文件:在os.listdir中查找扩展名

普洛特利express 发布的人口普查数据失败

Groupby并在组内比较单独行上的两个时间戳

将鼠标悬停在海运`pairplot`的批注/高亮显示上

意外的麻木图像reshape 为网格问题