如何从右下角移动顶层窗口

2024-10-02 10:24:19 发布

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

我想从桌面的bottom-right corner移动顶层窗口。我所能做的是把它放在右下角,但我想它从底部移动时,windows更新通知弹出

import tkinter as tk



def my_toplevel_from_corner():
    my_top = tk.Toplevel()

    window_height = 300
    window_width = 300

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

    x_cordinate = int((screen_width / 1.25) - (window_width / 2))
    y_cordinate = int((screen_height / 1.45) - (window_height / 2))  # 1.9 will make it ignore the task bar

    my_top.geometry("{}x{}+{}+{}".format(window_width, window_height, x_cordinate, y_cordinate))

    lr = tk.Label(my_top, text="SHOULD MOVE FROM BOTTOM RIGHT CORNER")
    lr.pack()



root = tk.Tk()
root.geometry("400x400")


la = tk.Label(text="TOPLEVEL SHOULD MOVE FROM BOTTOM RIGHT CORNER")
la.pack()




print("see if window is opened")


bt = tk.Button(root, text="OPEN TOPLEVEL WINDOW", command=my_toplevel_from_corner)
bt.pack(side=tk.BOTTOM)

root.mainloop()

description image


Tags: textfrommytoprootwindowwidthscreen

热门问题