【问题标题】:How to create Transparent text widget in python and tkinter?如何在 python 和 tkinter 中创建透明文本小部件?
【发布时间】:2019-07-08 06:13:10
【问题描述】:

python 和 tkinter 中的透明文本小部件,如玻璃记事本

【问题讨论】:

    标签: python-3.x tkinter


    【解决方案1】:

    对于 Windows,您可以创建一个 Text 小部件,指定背景颜色,然后使用 wm_attributes 将该颜色设置为透明。

    import tkinter as tk
    
    root = tk.Tk()
    text = tk.Text(root,bg="white")
    text.insert(tk.END,"This is a test message")
    text.pack()
    text.configure(font=("Times New Roman", 12, "bold"))
    root.wm_attributes("-transparentcolor", "white")
    root.mainloop()
    

    【讨论】:

    • 你能再回答一个问题吗?
    • 如何在python和tkinter中创建GUI设计器?
    • 只有windows吗@HenryYik?
    • @Shubham 这个问题太宽泛了,无法回答。如果您遇到卡住的特定部分,您可以发布问题,人们会提供帮助。
    • @ReblochonMasque 根据this post,没有跨平台的方式来保证背景透明,虽然我没有在 MacOS 或 Linux 上测试过上述方法。
    猜你喜欢
    • 2017-01-04
    • 2022-01-03
    • 2013-06-07
    • 2018-05-30
    • 2021-09-17
    • 2016-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多