-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimg_coordinates.py
More file actions
58 lines (43 loc) · 1.69 KB
/
Copy pathimg_coordinates.py
File metadata and controls
58 lines (43 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import tkinter as tk
from PIL import Image, ImageTk
import text_read.player_bounderies as player_feeds
class CordsPrint:
def __init__(self) -> None:
self.window = tk.Tk()
self.player_dict = player_feeds.PLAYERS
self.img = player_feeds.Reader()
self.img_status = None
self.index = 0
def create_window(self) -> None:
self.project_image()
self.window.mainloop()
def project_image(self) -> None:
key = list(self.player_dict)
if self.index < len(key):
input = self.player_dict[key[self.index]]
frame = self.img.spec_feed(input[0], input[1], input[2], input[3])
image = Image.fromarray(frame)
photo_image = ImageTk.PhotoImage(image=image)
if not self.img_status:
self.player_image = tk.Label(self.window)
self.player_image.pack()
self.next = tk.Button(self.window, text="next image", command=self.next_window)
self.next.pack()
self.img_status = self.player_image
self.player_image.bind("<Button-1>", self.print_coordinates)
self.player_image.photo_image = photo_image
self.player_image.configure(image=photo_image)
else:
self.window.destroy()
self.window.after(1000, self.project_image)
def print_coordinates(self, event) -> None:
x, y = event.x, event.y
print(f"Coordinates: ({x}, {y})")
def next_window(self) -> None:
self.index += 1
self.img_status = None
self.player_image.destroy()
self.next.destroy()
self.project_image()
c = CordsPrint()
c.create_window()