如何使用 Tkinter 建立多行輸入條例?
假設我們要建立一個支援多行使用者輸入的 Entry 小元件。為了建立一個多行 Entry 小元件,我們可以使用 Text() 建構函式。
示例
在此示例中,我們將建立一個視窗,其中包含多行 Entry 小元件。
#Import the library from tkinter import * #Create an object of tkinter window or frame win = Tk() #Define the geometry of window win.geometry("650x250") #Create an instance of Text Widget text = Text(win) text.pack() win.mainloop()
輸出
執行以上程式碼將顯示一個視窗,其中包含一個支援多行使用者輸入的文字小元件。
廣告