如何在 Tkinter 中設定輸入元件的字型大小?
Tkinter 中的輸入元件是一個基本的單行字元輸入框,它接受單行使用者輸入。為了設定其字型大小和寬度等輸入元件的屬性,我們可以定義一個內聯元件建構函式。
示例
下面是一個關於如何定義輸入元件的字型大小的示例。
# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Create an Entry widget entry=Entry(win, width=35, font=('Georgia 20')) entry.pack() win.mainloop()
輸出
執行以上程式碼以顯示包含定製的輸入元件的視窗。
廣告