import urllib.request import time from PIL import Image, ImageTk import io import tkinter as tk url = "https://pb.gulyaipole.fun/" root = tk.Tk() canvas = tk.Canvas(root) canvas.pack() root.geometry("1024x800") root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file='map.png')) ttext = tk.Canvas(root, width=90, height=20, bg="black") ttext.place(x=940, y=0) text = ttext.create_text(40, 10, text="X: 1, Y: 1", fill="white") while True: x = root.winfo_pointerx() - root.winfo_rootx() y = 800 - (root.winfo_pointery() - root.winfo_rooty()) ttext.itemconfig(text, text=f"X: {x}, Y: {y}") # Открываем URL как файл image_file = io.BytesIO(urllib.request.urlopen(url).read()) # Открываем изображение в PIL img = Image.open(image_file) # Преобразуем изображение в формат, поддерживаемый Tkinter tk_img = ImageTk.PhotoImage(img) # Создаем новый Canvas для вывода изображения canvas = tk.Canvas(root, width=img.size[0], height=img.size[1]) canvas.create_image(0, 0, anchor="nw", image=tk_img) #canvas.pack() canvas.place(x=0, y=0) try: canvas_old.destroy() except: pass canvas_old = canvas tk.Misc.lift(ttext) # Обновляем окно root.update() time.sleep(0.1) root.mainloop()