如何使窗口保持在底部?

2024-04-18 12:02:12 发布

您现在位置:Python中文网/ 问答频道 /正文

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

窗户总是在我打开的所有窗户的顶部。我希望它像墙纸一样留在底部。提前谢谢!在


Tags: fromimportconfigclosetkinterdefbuttonroot
1条回答
网友
1楼 · 发布于 2024-04-18 12:02:12

你已经在做一些接近的事情了。得到屏幕高度并减去窗口的高度或更多。在

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

相关问题 更多 >