在 Tkinter 窗口中创建透明背景\n\n
Tkinter 窗口提供了许多内置的函数和属性来帮助应用程序无缝运行。它们还会配置应用程序的 GUI。
假如我们想要在应用程序中创建一个透明窗口,那么必须在 attributes('-transparentcolor', 'color' ) 方法中定义颜色。通过提供该窗口和小组件的颜色,它会使该窗口变为透明的。
示例
#Import the Tkinter Library
from tkinter import *
#Create an instance of Tkinter Frame
win = Tk()
#Set the geometry of window
win.geometry("700x350")
#Add a background color to the Main Window
win.config(bg = '#add123')
#Create a transparent window
win.wm_attributes('-transparentcolor','#add123')
win.mainloop()输出
运行以上代码将显示一个带有透明背景的窗口。

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP