gpt4 book ai didi

python - Tkinter wm_attributes 没有 Linux 中的所有选项

转载 作者:行者123 更新时间:2023-12-04 08:27:21 25 4
gpt4 key购买 nike

我想在 Linux (Python3.x) 中使用 Tkinter 创建一个 GUI。当我尝试执行以下操作时:-

from tkinter import *
import tkinter


root = Tk()
root.overrideredirect(True) # Hide the cross button and that bar
root.wait_visibility(root)
root.call("wm", "attributes", ".", "-transparent", "true")



root_w = 190
root_h = 190

win_w = root.winfo_screenwidth()
win_h = root.winfo_screenheight()


root.geometry(f'{root_w}x{root_h}+{win_w - root_w - 40}+{win_h - root_h - 40}')



samplabl = Button(root, text=f"WIDTH: {win_w} HEIGHT: {win_h}", bg='#ffffff')

samplabl.pack()

root.mainloop()

这是我得到的:-

Traceback (most recent call last):
File "/home/bravo6/Desktop/Stella__Compilative/GUI/temp.py", line 8, in <module>
root.call("wm", "attributes", ".", "-transparent", "true")
_tkinter.TclError: bad attribute "-transparent": must be -alpha, -topmost, -zoomed, -fullscreen, or -type

看起来 wm_attribute 没有识别 -transparent 属性......似乎它只适用于 Windows。知道如何让它在 Linux 中运行吗?

最佳答案

你无能为力。不同的操作系统支持不同的窗口管理器选项。在我写这篇文章的时候,这些是每个窗口系统支持的属性:

所有平台:alpha全屏topmostOSX:modifiednotifytitlepathtransparentWindows:已禁用toolwindowtransparentcolor基于 X11 的系统(即:linux,并且仅使用一些窗口管理器):typezoomed

关于python - Tkinter wm_attributes 没有 Linux 中的所有选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65196133/

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