請問我該如何銷燬這個tkinter窗口?如何銷燬這個tkinter窗口
from Tkinter import *
import time
def win():
root = Tk()
root.wait_visibility(root)
root.attributes('-alpha', 0.7)
root.overrideredirect(True)
root.configure(background='black')
root.wm_attributes("-topmost", 1) #zostane navrchu
w = 200 # width for the Tk root
h = 50 # height for the Tk root
# get screen width and height
ws = root.winfo_screenwidth() # width of the screen
hs = root.winfo_screenheight() # height of the screen
# calculate x and y coordinates for the Tk root window
x = (ws/2) - (w/2)
y = hs - h - 50 #(hs/2) - (h/2)
lab = Label(root, text="Hello, world!")
lab.pack()
#x = 50
#y = 50
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root.mainloop()
app = win()
app.destroy() #not working
你是正確的,win()不返回一個值;不過,您建議的解決方案也不行。在調用root.quit之前,函數'mainloop'不會返回。 –
是的,你是對的我正在編輯它,以顯示他如何把一個按鈕,並將其設置爲銷燬,我評論的鏈接實際上是哈哈 – Mixone