我的标签没有显示Python Tkinter

时间:2018-03-27 16:42:15

标签: python tkinter

from tkinter import *
#Making the frame_____________
class Window(Frame):

    def __init__(self, master = None):
        Frame.__init__(self,master)

        self.master = master

        self.init_window()
#_____________________________
#Making the actual window
    def init_window(self):

        self.master.title("Ethics and similar topics quiz")#Title along the top of the window

        self.pack(fill=BOTH, expand=1)

        StartButton = Button(self, text="Start Quiz", fg = "Purple",  command=self.showtxt)

        StartButton.config(height = 4 , width = 25)

        StartButton.place(x=815, y=1)#Positions it

    def showtxt(self):
        text1 = Label(self, text= "What is the meaning of the word 'Ethical'?")
        text1.pack

有我的代码,出于某种原因,当我在开始按钮之外添加任何其他内容时,它不会显示在我的窗口上。有什么问题?

1 个答案:

答案 0 :(得分:0)

您需要使用text1.pack()而不是text1.pack。有关pack()功能的说明,请参阅here