0
使用pack_forget时做出部件再次可见我有这样的代码:如何在Tkinter的
# -*- coding: utf-8 -*-
def clear_screen():
button2.pack_forget()
button3.pack_forget()
text.pack_forget()
label.pack_forget()
def main_page():
var = StringVar()
label = Label(root, textvariable=var)
var.set("Fill in the caps: ")
label.pack()
global text
text = Text(root,font=("Purisa",12))
text.pack()
global button
button=Button(root, text ="Create text with caps.", command =lambda: full_function())
button.pack()
def clear_and_main():
clear_screen()
main_page()
def full_function():
global button2
global button3
button3=Button(root, text ="Main page", command=lambda: clear_and_main())
button3.pack()
button2=Button(root, text ="Answer")
button2.pack()
button.pack_forget()
from Tkinter import *
root = Tk()
main_page()
root.mainloop()
我想这个程序工作的方式,如果我点击按钮“主页”,它会重新创建主页。但事实并非如此。文本框和按钮不会重新出现。我怎样才能让它工作正确?