【问题标题】:How can I turn a transparant background visible again in tkinter?如何在 tkinter 中再次显示透明背景?
【发布时间】:2021-05-24 21:09:08
【问题描述】:

我正在使用 Python Tkinter my_label.master.wm_attributes("-transparentcolor", "white") 将新弹出标签的背景变为透明,并使用 my_label.master.wm_attributes("-transparentcolor", "grey") 使其再次可见。这是有效的,因为我有一个白色背景,上面有黑色字母。 但这对我来说似乎有点贪婪。 是否有其他方法可以让背景再次可见?

【问题讨论】:

  • 您是否尝试过使用:.attributes("-transparentcolor", "none")
  • 使用my_label.master.attributes("-transparentcolor", "none")时会报错:unknown color name "none"
  • 来自this 尝试.attributes("-transparentcolor", "") 是合理的
  • 这成功了。非常感谢。
  • 没问题。诀窍是谷歌它(它没有工作)。如果这没有帮助,请查看文档。几个小时前我在看那个页面,但它仍然打开。

标签: python tkinter background label transparency


【解决方案1】:

来自tcl's documentation如果指定空字符串(默认),则不使用透明色。

也就是说你可以使用.attributes("-transparentcolor", "")来重置窗口的透明颜色。

【讨论】:

    猜你喜欢
    • 2017-10-07
    • 1970-01-01
    • 2015-07-22
    • 2019-03-31
    • 2012-05-14
    • 1970-01-01
    • 2013-03-30
    • 2022-01-24
    相关资源
    最近更新 更多