python Tkinter大神请进
发布网友
发布时间:2022-04-21 10:09
我来回答
共1个回答
热心网友
时间:2022-04-18 17:31
# _*_ coding: utf-8 _*_
from Tkinter import *
def exit_chile(child):
child.destroy()
def pop_up_window():
top = Toplevel()
top.geometry('300x300')
#set up the button to exit
button2 = Button(top, text='quit', bg='red', command=lambda m = top :exit_chile(m))
button2.pack()
root = Tk()
root.title("test child widget")
root.geometry("600x500")
#set up the button for pop up a child window.
button1 = Button(root, text="弹出一个窗口", command=pop_up_window)
button1.pack()
root.mainloop()
把上面的输进去运行试试,希望可以帮到你。代码中没有用class,比较短的程序用def 定义一个函数逻辑往往更加清晰。