如何更新 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