简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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