寬度width高度height來源source=src from tkinter import * #從tkinter函式庫輸入所有函式,檔案'window001.py' import time #412單元延續數入time套件 def delete(): #增加自訂函數def delete() List[int(n.get())-1].destroy() #destroy破壞視窗List[索引] window.config(bg='#10ff10') b1=Label(window,text='謝孜妤',font='Arial 100 bold',bg='#10ff10').pack() x=('三','二','一','\U0001F605','\U0001F600','\U0001F4A9') #建立元祖tuple名為x,0,1,2,3,4,5 List = [] #建立串列list名為List window=toplevel() window.geometry('400x200+800+0') window.title('謝孜妤控制原來的視窗') n = StringVar(window) #類別變數 n.set('刪除') op1 = OptionMenu(window,n,1,2,3,4,5,6).pack() bu1 = Button(window,text='刪除選取視窗',command=delete,font='20',bg='blue',fg='white') bu1.pack() for i in range(6): window = Tk() window.title('謝孜妤第%d個視窗' % (i+1)) window.geometry('300x300+%d+%d' % (i*300,i*100)