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

該窗口始終位於我打開的所有窗口的頂部。 我希望它像壁紙一樣停留在底部。 提前致謝!

您已經在做一些接近的事情。 獲取屏幕高度,然后減去窗口的高度或更多。

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