英文:
Setting a tkinter window to be fullscreen using "-fullscreen" attribute after changing resolution with ctypes does not resize the window correctly
问题
我有一个使用ctypes缩放过的tkinter窗口。当我尝试使用"-fullscreen"属性使窗口全屏时,窗口不会调整大小以覆盖整个屏幕,而只会覆盖屏幕的一半。
示例:
import tkinter as tk
import ctypes
window = tk.Tk()
window.tk.call('tk', 'scaling', 2) ## 将窗口的缩放比例加倍
ctypes.windll.shcore.SetProcessDpiAwareness(2) ## 将窗口的分辨率加倍
## 窗口现在有双倍分辨率和1倍缩放比例
window.attributes("-fullscreen", True) ## 将窗口设置为全屏模式不正常工作
window.mainloop()
此外,我不知道这是否与winfo_screenwidth/height有关,但它返回了不正确的屏幕宽度和高度值。
感谢任何帮助。
英文:
I have a tkinter window that has been scaled using ctypes. When I try to make the window full-screen using the "-fullscreen" attribute, the window does not resize to cover the screen and instead, only covers half the screen.
Example:
import tkinter as tk
import ctypes
window = tk.Tk()
window.tk.call('tk', 'scaling', 2) ## Double the scale of the window
ctypes.windll.shcore.SetProcessDpiAwareness(2) ## Double the resolution of the window
## Window now has double resolution with 1x scale
window.attributes("-fullscreen", True) ## Making window full-screen doesn't work properly
window.mainloop()
Also, I don't know if this is related, but winfo_screenwidth/height returns an incorrect value for the screen width and height.
Thanks for any help.
答案1
得分: 0
用以下内容替换:
window.attributes("-fullscreen", True)
为:
window.geometry(f"{window.winfo_vrootwidth()}x{window.winfo_screenheight()}+{-7}+0")
你这么做了吗?
英文:
How about replacing
window.attributes("-fullscreen", True)
with
window.geometry(f"{window.winfo_vrootwidth()}x{window.winfo_screenheight()}+{-7}+0")
did you?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论