簡體   English   中英

如何在python和tkinter中創建透明文本小部件?

[英]How to create Transparent text widget in python and tkinter?

python和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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM