Python tkinter-加密窗口显示缩放

发布于 2025-02-10 01:51:47 字数 120 浏览 2 评论 0原文

我的程序具有固定的分辨率主窗口,我不希望它可以解析,但是某些具有很小监视器的PC具有很高的显示器捕获设置,因此该程序无法显示完整的窗口,有没有办法提取此缩放系数我可以加盟吗?还是有一种方法可以编译EXE,以免根据设置进行扩展?

My program has a fixed resolution main window, i dont want it to be resizable, but some PCs with very small monitors will have high display scalling setting, so the program cannot show the full window, is there a way to extract this scaling factor so i can conpensate that? Or is there a way to compile the exe so that it does not scale according to the settings?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遮了一弯 2025-02-17 01:51:47

您可以使用CTYPE获取缩放系数,然后根据它修改尺寸。

import ctypes

scale_factor = ctypes.windll.shcore.GetScaleFactorForDevice(0)

如果比例因子= 150%,则将返回150。
当您在应用程序中使用此号码时,将100除以100。

You can get the scaling factor using ctype and then modify your dimensions according to it.

import ctypes

scale_factor = ctypes.windll.shcore.GetScaleFactorForDevice(0)

If scale factor = 150%, this will return 150.
Its probably useful to divide by 100 when your working with this number in your app.

于我来说 2025-02-17 01:51:47

如果我正确理解您,您的问题的答案如下:


fixedWidth = 1920
fixedHeight = 1080

user_monitor = get_monitors()
scale = user_monitor.width / fixedWidth

if user_monitor.widht < fixedWidth:
    fixedWidth = user_monitor.width
if user_monitor.height < fixedHeight:
    fixedHeight = user_monitor.height

当然,您必须乘以scale其余的程序大小来缩小程序的规模

If I understood you correctly, the answer for your problem is below:


fixedWidth = 1920
fixedHeight = 1080

user_monitor = get_monitors()
scale = user_monitor.width / fixedWidth

if user_monitor.widht < fixedWidth:
    fixedWidth = user_monitor.width
if user_monitor.height < fixedHeight:
    fixedHeight = user_monitor.height

and of course you have to multiply by scale the rest of you program sizes to scale down your program

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文