2016-09-22 44 views
0
import Tkinter 
from Tkinter import Button 
root=Tkinter.Tk() 
def close_window(): 
    root.destroy() 
w = root.winfo_screenwidth() 
root.overrideredirect(1) 
root.geometry("200x200+%d+200" %(w-210)) 
root.configure(background='gray10') 
btn = Button(text='X',borderwidth=0,highlightthickness=0,bd=0,command = close_window,height="1",width="1") 
btn.pack() 
btn.config(bg='gray10', fg='white') 
btn.config(font=('helvetica', 8)) 
root.mainloop() 

窗口始終停留在我打開的所有窗口的頂部。我希望它像牆紙一樣留在底部。提前致謝!如何讓tkinter窗口停留在底部?

回答

0

你已經在做一些事情了。獲取屏幕高度並減去窗口的高度或更多。

import Tkinter 
from Tkinter import Button 

root=Tkinter.Tk() 
def close_window(): 
    root.destroy() 

screen_width = root.winfo_screenwidth() 
screen_height = root.winfo_screenheight() 

root.overrideredirect(1) 
root.geometry("200x200+{0}+{1}".format(screen_width-210, screen_height-210)) 
root.configure(background='gray10') 

btn = Button(text='X', borderwidth=0, highlightthickness=0, bd=0, command=close_window, height="1", width="1") 
btn.pack() 
btn.config(bg='gray10', fg='white') 
btn.config(font=('helvetica', 8)) 

root.mainloop()