如何更新 Tkinter 中網格中的資訊?
讓我們假設一個 Tkinter 應用程式在視窗中放置了小部件,並使用 Grid 幾何管理器。為了更改 Tkinter 小部件的屬性,我們可以使用 **configure(**options)** 方法。在視窗中渲染小部件時,我們必須將建構函式分配給變數,透過這些變數可以全域性更改小部件的屬性。
示例
# Import the required libraries
from tkinter import *
# Create an instance of tkinter frame or window
win=Tk()
# Set the size of the window
win.geometry("700x350")
# Add a Label widget and assign it to a new variable
label=Label(win, text="This is Houstan Control. " "We've detected a new Mission", background="skyblue",font=('Aerial 11'))
label.grid(row=0, column=2)
win.mainloop()輸出
執行上面的程式碼將顯示一個視窗,其中有一個標籤小部件與視窗的最左邊對齊。
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP