[英]how to open a new window, after user has finished the previous program, tkinter?
實際上我的代碼所做的是,詢問一些信息,然后當他/她完成時,我會將她移至下一頁,要求她輸入 Email 和密碼:
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
好吧,代碼的 rest 只是操作
我除了是,當用戶完成並單擊按鈕(我在我的代碼中有它)時,window 被關閉,新的 window 被打開
我的問題是如何關閉以前的 window 以及在哪里可以開始和打開新的 window?
您可以使用 destroy 語句來執行此操作:
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.