How can I open a new window when the user clicks the button?

后端 未结 2 536
感动是毒
感动是毒 2021-01-26 02:12

How would I create a new window when the user clicks a button (still needs creating)? I have took some code out to make this shorter. I need a button creating and when they hit

2条回答
  •  萌比男神i
    2021-01-26 02:41

    Use a Toplevel to open a new one. Modify your code as shown below.

    self.NewWindow = tkinter.Button(self.master, 
                                    text="New Window", 
                                    command=self.CreateNewWindow)
    
     def CreateNewWindow(self):
         self.top = tkinter.Toplevel()
         self.top.title("title")
    

提交回复
热议问题