gpt4 book ai didi

python - kivy 应用程序在具有高分辨率屏幕的 Windows 上模糊

转载 作者:行者123 更新时间:2023-12-05 01:52:10 27 4
gpt4 key购买 nike

我的 kivy 应用程序有问题。我的高分辨率 Windows 笔记本电脑 (3840x2160) 上的文字很模糊。它在具有视网膜显示屏的 Mac 和较低分辨率的 Windows PC 上运行良好。如以下屏幕截图所示。

screenshot of app

这是我的测试代码:

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.config import Config
Config.set('graphics', 'width', '200')
Config.set('graphics', 'height', '100')

class MyApp(App):
def build(self):
return Label(text="why is this blurry")

if __name__ == "__main__":
MyApp().run()

这是控制台输出:

[INFO   ] [Logger      ] Record log in C:\Users\lucas\.kivy\logs\kivy_22-04-01_6.txt
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.2
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.4.5
[INFO ] [Kivy ] v2.1.0
[INFO ] [Kivy ] Installed at "C:\Users\lucas\kivytest\env\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)][INFO ] [Python ] Interpreter at "C:\Users\lucas\kivytest\env\Scripts\python.exe"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.14757 Compatibility Profile Context FireGL 20.45.01.45 27.20.14501.45003'>
[INFO ] [GL ] OpenGL vendor <b'ATI Technologies Inc.'>
[INFO ] [GL ] OpenGL renderer <b'AMD Radeon(TM) Pro Graphics'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Base ] Start application main loop
[INFO ] [GL ] NPOT texture support is available

这个问题似乎与此有关:https://github.com/kivy/kivy/issues/3705

或者这个:https://github.com/kivy/kivy/pull/7299

或者这个:https://github.com/kivy/kivy/pull/7293

但是这些建议似乎都不适合我。知道如何解决这个问题吗?

最佳答案

解决方案基本上在我发布的第二个链接中:https://github.com/kivy/kivy/pull/7299

当我在这里没有得到任何回复时,我也在该线程中发布了一个问题,但会在此处复制我的解决方案。

当我执行以下操作时:

from ctypes import windll
windll.user32.SetProcessDpiAwarenessContext(-4)
lastError = windll.kernel32.GetLastError()
print(lastError)

我得到了对应于 ERROR_INVALID_PARAMETER 的错误 87。所以 -4 一定有问题。我在 windll 周围挖掘并找到了以下修复方法:

from ctypes import windll, c_int64
windll.user32.SetProcessDpiAwarenessContext(c_int64(-4))

关于python - kivy 应用程序在具有高分辨率屏幕的 Windows 上模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71704354/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com