在 Python Tkinter 中建立無邊框視窗
Tkinter 是用於建立基於 GUI 的應用程式最常用的 Python 庫。它具有像新增小部件和其他必需屬性之類的功能。
假設我們想要使用 tkinter 建立無邊框視窗。為了建立無邊框視窗,我們可以使用overrideredirect方法,該方法在基本面上停用視窗並移除視窗元素,如關閉按鈕、標題、最小化元素和按鈕等。
overrideredirect是一個布林函式,它可以是 True 或 False。一旦開啟視窗,可以透過按 Alt+F4 來關閉它。
示例
#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")
#Define the window text widget
lab= Label(win, text= "Hello World", font=('Time New Roman', 35), fg="green", anchor= "c").pack()
#Make the window borderless
win.overrideredirect(True)
win.mainloop()輸出
執行上述程式碼會生成輸出並顯示無邊框視窗。

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP