【问题标题】:python tkinter label widgit not appearing in windowpython tkinter标签widgit没有出现在窗口中
【发布时间】:2020-04-09 16:47:28
【问题描述】:

我正在使用 tkinter,我正在尝试制作一个未出现的 Label 小部件。我创建标签的行执行,但是窗口上没有显示任何内容。

from tkinter import * class const():
    def __init__(self,par):
        self.parent = par
        self.window = Toplevel()
        self.window.title("ZZ")
        self.window.geometry("200x250")
        self.window.protocol("WM_DELETE_WINDOW", self.parent.quit)
        self.bnl = []
        self.count = 0
        self.dic = {1: '', 2: '', 3: '', 4: '', 5: '', 6: '', 7: '', 8: '', 9: ''}
        self.lbl=Label(par, text="Begin",font=("Arial",64),fg="BLACK",bg="RED")
        self.lbl.grid(row=4,column=0,columnspan=3)

【问题讨论】:

  • 你运行 mainloop() 吗?
  • 是的,其他小部件按预期工作。

标签: python python-3.x tkinter


【解决方案1】:

self.lbl=Lab​​el(par, text="Begin",font=("Arial",12),fg="BLACK")

此行有错误,但以下行工作正常:

self.lbl=Lab​​el(self.window, text="Begin",font=("Arial",12),fg="BLACK")

【讨论】:

    猜你喜欢
    • 2023-01-25
    • 2012-02-21
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多