how to open a new window, after user has finished the previous program, tkinter?

Viewed 25

actually what my code does is, asking for some information and then when he/she finishes,I will move her to the next page, which asks her for Email and password:

import tkinter as tk
from tkinter import ttk

class Bio():
    
    def __init__(self):
        self.window = tk.Tk()
        self.frame = tk.Frame(self.window)
        self.window.title('Data form')
        self.frame.pack()

    def main(self):
        Bio.personaly(self)
        Bio.information(self)
        Bio.beruflich(self)
        Bio.term_accept(self)
        Bio.enter(self)
        Bio.retrive(self)
        self.window.mainloop()  # Runs 'til i quit

well, The rest of the code is just operations

what i except is, When the user finishes and clicks the button (i have it in my code), the window is closed and a new window is opened

my question is how can i close the previous window and where can i start and open the new window?

1 Answers

You can do it like this withe the destroy statement:

import tkinter as Tk
from tkinter import *

root = Tk()
width= root.winfo_screenwidth()               
height= root.winfo_screenheight()
root.geometry("%dx%d" % (width, height))
root.title("selfdestruction")
root.config(bg="black")

def exit():
    root.destroy()

destroy_button   =   Button(root, text="exit",command=lambda: exit()) 
destroy_button.place(relx=0.5, rely=0.5, anchor="center")

root.mainloop()
Related