在 Python Tkinter 中建立透明視窗


Python 是用於開發和建立函式和桌面應用程式的最流行語言。它擁有豐富的不同模組和函式庫,可提供可擴充套件性和可訪問性以建立和開發應用程式。

Tkinter 是用於建立基於 GUI 的應用程式的最常用庫。它具有新增小部件和其他必要屬性等功能。

假設我們想要使用 tkinter 建立一個透明視窗。為了建立透明視窗,我們可以使用 attributes 屬性並定義 opacity 值。

示例

#Importing the tkinter library
from tkinter import *

#Create an instance of tkinter frame
win= Tk()

#Define the size of the window or frame
win.geometry("700x400")

#To Make it transparent use alpha property to define the opacity of
the frame
win.attributes('-alpha', 0.3)
win.mainloop()

輸出

執行以上程式碼將產生輸出並顯示一個透明視窗。

更新於:04-Mar-2021

859 次瀏覽

開啟你的 事業

完成課程獲得認證

立即開始
廣告
© . All rights reserved.