简体   繁体   English

如何使tkinter窗口停留在底部?

[英]how to make tkinter window to stay at bottom?

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()

the window always stay at top of all the windows that i open. 该窗口始终位于我打开的所有窗口的顶部。 i want it to stay at the bottom like the wallpaper. 我希望它像壁纸一样停留在底部。 Thanks in advance! 提前致谢!

You're already doing something close. 您已经在做一些接近的事情。 Get the screen height and subtract the height or more of your window. 获取屏幕高度,然后减去窗口的高度或更多。

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM