python Tkinter GUI未显示输出窗口

kq0g1dla  于 2023-05-27  发布在  Python
关注(0)|答案(1)|浏览(120)
from tkinter import *
THEME_COLOR = "#375362"

class QuizInterface():
    def __int__(self):
        # super().__int__()
        self.window = Tk()
        self.window.title('Quizzler')
        self.window.config(pady=20,padx=20,bg=THEME_COLOR)

        self.score_label = Label(text="Score: 0",fg="white",bg=THEME_COLOR)
        self.score_label.grid(row=0,column=1)

        self.canvas = Canvas(width=300,height=250,bg="white")
        self.question_text = self.canvas.create_text(text="Some Question Text",fill=THEME_COLOR)
        # self.question_text = self.canvas.create_text(150,125,text="Some Question Text", fill=THEME_COLOR)
        self.canvas.grid(row=1,column=0,columnspan=2)

        self.window.mainloop()

我试着在这里和YouTube上搜索解决方案,但我没有找到。

2cmtqfgy

2cmtqfgy1#

您只是创建了一个类,但实际上并没有使用该类创建一个对象。你必须做一些事情

quiz_interface = QuizInterface()

最后,调用init函数

相关问题