我想在Linux中用Tkinter创建一个GUI (Python3.x)。当我试图执行以下操作时:
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中工作吗?
发布于 2020-12-08 14:34:49
你无能为力。不同的操作系统支持窗口管理器的不同选项。在我编写这篇文章时,以下是每个窗口系统所支持的属性:
:alpha
、fullscreen
、topmost
OSX:modified
、notify
、titlepath
、transparent
E 111
WindowsE 212
:disabled
、d14、transparentcolor
E 116基于X11的系统E 217(即: linux,只包含一些窗口管理器):type、zoomed
https://stackoverflow.com/questions/65196133
复制相似问题