[英]How can I resize the window to fill the full screen height but a specified screen width?
[英]How to create window with full screen width/height in tkinter?
我正在尝试创建一个全屏大小的 window,但不是两个坐标,只有宽度或高度。 Windows 中的一些 windows 跨越全高或全宽,我的 window 应该是这样出现的。
我尝试做可调整大小的全屏模式,但这不是我想要的。 有没有标志或方法可以做到这一点?
编辑:我尝试使用几何方法、state 方法和 attrinbutes 方法
window.attributes('-fullscreen', True)
它没有帮助,因为它不允许您看到 Windows 工具栏并通过两个坐标使 window 全尺寸,我只需要 1 - 宽度和高度
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
window.geometry("%dx%d" % (width, height/2))
它不太干净,window 有点未对齐。
window_name.state('zoomed')
这似乎很有帮助,但是state
在两个方向上都最大化了,我不知道我是否可以在 1 个方向上轻松地做同样的事情
如果你想要全屏 window,使用:
win = Tk()
win.attributes('-fullscreen', True)
如果你只是想让它在一个方向上全屏,你可以先获取屏幕的高度/宽度,然后设置 window 大小:
win = Tk()
screen_width = win.winfo_screenwidth()
screen_height = win.winfo_screenheight()
# replace either screen_width and screen_height to change the appropriate dimension
win.geometry(f"{screen_width}x{screen_height}")
win.mainloop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.