import tkinter as tk
root = tk.Tk()
root.geometry('200x100')
x = 100
y = 100
move_x = 2
move_y = 2
def move_window():
global x, y, move_x, move_y
x += move_x
y += move_y
if x + 200 >= root.winfo_screenwidth() or x <= 0:
move_x = -move_x
if y + 100 >= root.winfo_screenheight() or y <= 0:
move_y = -move_y
root.geometry(f'+{x}+{y}')
root.after(10, move_window)
move_window()
root.mainloop()