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.
70 lines
1.4 KiB
70 lines
1.4 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()
|
|
root.geometry("1280x720")
|
|
|
|
# Canvas for image
|
|
canvas = tk.Canvas(root)
|
|
canvas.pack()
|
|
|
|
# XY cords
|
|
ttext = tk.Canvas(root, width=100, height=20, bg="black")
|
|
ttext.place(x=1180, y=0)
|
|
text = ttext.create_text(50, 10, text="X: 1, Y: 1", fill="white")
|
|
|
|
# Run threads
|
|
from threading import Thread
|
|
from time import sleep
|
|
|
|
def cords_up():
|
|
while True:
|
|
x = root.winfo_pointerx() - root.winfo_rootx()
|
|
y = 720 - (root.winfo_pointery() - root.winfo_rooty())
|
|
ttext.itemconfig(text, text=f"X: {x}, Y: {y}")
|
|
sleep(0.05)
|
|
|
|
cords = Thread(target=cords_up)
|
|
cords.start()
|
|
|
|
def image_up():
|
|
global canvas_old, canvas
|
|
|
|
while True:
|
|
# Prepare image for tkiner
|
|
image_file = io.BytesIO(urllib.request.urlopen(url).read())
|
|
img = Image.open(image_file)
|
|
tk_img = ImageTk.PhotoImage(img)
|
|
|
|
# Create new canvas
|
|
canvas = tk.Canvas(root, width=img.size[0], height=img.size[1])
|
|
canvas.create_image(0, 0, anchor="nw", image=tk_img)
|
|
canvas.place(x=0, y=0)
|
|
|
|
try:
|
|
# New canvas and cords up
|
|
tk.Misc.lift(canvas)
|
|
tk.Misc.lift(ttext)
|
|
# Update
|
|
root.update()
|
|
sleep(2)
|
|
# Remove ols
|
|
canvas_old.destroy()
|
|
except:
|
|
pass
|
|
# New canvas now is old
|
|
canvas_old = canvas
|
|
|
|
image = Thread(target=image_up)
|
|
image.start()
|
|
|
|
|
|
|
|
root.mainloop()
|
|
|