You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

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()
11 months ago
root.geometry("1280x720")
ttext = tk.Canvas(root, width=90, height=20, bg="black")
11 months ago
ttext.place(x=1180, y=0)
text = ttext.create_text(40, 10, text="X: 1, Y: 1", fill="white")
while True:
x = root.winfo_pointerx() - root.winfo_rootx()
11 months ago
y = 720 - (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()
11 months ago
#