【发布时间】:2019-07-08 06:13:10
【问题描述】:
python 和 tkinter 中的透明文本小部件,如玻璃记事本
【问题讨论】:
标签: python-3.x tkinter
python 和 tkinter 中的透明文本小部件,如玻璃记事本
【问题讨论】:
标签: python-3.x tkinter
对于 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()
【讨论】: