Python-坚持为猜谜游戏创建新框架

时间:2019-07-02 07:52:19

标签: python tkinter

所以我已经有了代码,但是我不知道为什么当我实际运行代码时它没有显示。原始代码有效,但是当我为新框架添加内容时,它下面的内容将无效。

我以前在那里有一个空白空间,所以我尝试使用相同的行和列替换那里的按钮,但仍然无法正常工作。

    # Create label for name    
    self.name_lbl = Label(self, text = "Player Name: ")
    self.name_lbl.grid(row = 1, column = 0, sticky = W)

    # Create entry widget to accept name      
    self.name_ent = Entry(self)
    self.name_ent.grid(row = 1, column = 1, sticky = W)


    """ Guess Input """ 

    # Create label for entering Guess  
    self.guess_lbl = Label(self, text = "Enter your Guess.")
    self.guess_lbl.grid(row = 2, column = 0, sticky = W)

    # Create entry widget to accept Guess  
    self.guess_ent = Entry(self)
    self.guess_ent.grid(row = 2, column = 1, sticky = W)

    # Create a space  
    # self.gap1_lbl = Label(self, text = " ")
    # self.gap1_lbl.grid(row = 3, column = 0, sticky = W)

这是我运行代码时不显示的地方

def raise_frame(frame):
    frame.raiser()
    """Making Next level button"""
    root = Tk()

    f1 = Frame(root)
    f2 = Frame(root)


    for frame in (f1, f2):
        frame.grid(row=3, column=0, sticky=W)


    #button    
        self.level_bttn = Button(self, text='Next level',command= lambda:raise_frame(f2))
        self.level_bttn.grid(row= 3, column = 0, sticky = W)


    raise_frame(f1)

    """ Submit Button """

    # Create submit button
    self.submit_bttn = Button(self, text = "Submit", command = self.reveal)
    self.submit_bttn.grid(row = 4, column = 0, sticky = W)

    # Create a space  
    self.gap2_lbl = Label(self, text = " ")
    self.gap2_lbl.grid(row = 7, column = 0, sticky = W)

    """ RESET """

    # Create submit button
    self.reset_bttn = Button(self, text = "Reset", command = self.reveal)
    self.reset_bttn.grid(row = 6, column = 1, sticky = W)

我希望它显示在猜测小部件之后和“提交”按钮之前。

0 个答案:

没有答案