如何在 Tkinter 中更改標題欄?
Tkinter 最初為每個應用程式設定了一個預設標題欄。我們可以透過配置 title("輸入任意標題") 方法來更新或替換 Tkinter 應用程式的標題欄。對於特定的應用程式,讓我們看看如何更改計算數字平方的 Tkinter 應用程式的標題。
示例
#Import the required Libraries
from tkinter import *
from tkinter import ttk
import math
#Create an instance of Tkinter frame
win = Tk()
#Set the geometry of tkinter frame
win.geometry("750x270")
#Set the Title of Tkinter window
win.title("Square Calculator")
def find_square():
no= int(entry.get())
Label(win, text=no*no).pack()
#Create an entry widget to accept user input
entry= Entry(win, width=40)
entry.pack(ipadx= 20,pady=20)
#Create a button to calculate the number
ttk.Button(win, text= "Calculate", command= find_square).pack()
win.mainloop()輸出
上述程式計算條目小部件中給定數字的平方。因此,程式視窗標題已重新命名為“平方計算器”。
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP