Add image-preview + cords of this image.
This commit is contained in:
parent
cc3bc15ac8
commit
87938079b3
42
gpt_blob.py
Normal file
42
gpt_blob.py
Normal file
@ -0,0 +1,42 @@
|
||||
import tkinter as tk
|
||||
from time import sleep
|
||||
|
||||
def start_drag(event):
|
||||
global current_coords
|
||||
global dragged_item
|
||||
dragged_item = label
|
||||
current_coords = label.winfo_pointerx(), label.winfo_pointery()
|
||||
|
||||
def stop_drag(event):
|
||||
dragged_item = None
|
||||
|
||||
def drag(event):
|
||||
global current_coords
|
||||
xc, yc = label.winfo_pointerx(), label.winfo_pointery()
|
||||
dx, dy = xc - current_coords[0], yc - current_coords[1]
|
||||
current_coords = xc, yc
|
||||
label.place(x=label.winfo_x() + dx, y=label.winfo_y() + dy)
|
||||
|
||||
def nn(root,im):
|
||||
global label
|
||||
|
||||
image = tk.PhotoImage(file=im) # Use self.image
|
||||
label = tk.Label(root, image=image)
|
||||
label.image = image # Keep a reference to the image
|
||||
label.pack()
|
||||
|
||||
dragged_item = None
|
||||
current_coords = 0, 0
|
||||
|
||||
label.bind('<ButtonPress-1>', start_drag)
|
||||
label.bind('<ButtonRelease-1>', stop_drag)
|
||||
label.bind('<B1-Motion>', drag)
|
||||
# globals().update(locals())
|
||||
|
||||
while True:
|
||||
tk.Misc.lift(label)
|
||||
sleep(0.05)
|
||||
|
||||
print("Image cords: ", label.winfo_x(), 670 - label.winfo_y())
|
||||
#x1, y1 = image.coords(image)
|
||||
# print(f'Image cords: {}')
|
29
map.py
29
map.py
@ -32,8 +32,27 @@ def cords_up():
|
||||
cords = Thread(target=cords_up)
|
||||
cords.start()
|
||||
|
||||
def image_up():
|
||||
global canvas_old, canvas
|
||||
|
||||
|
||||
#### WARN, GPT-BLOB ####
|
||||
|
||||
from gpt_blob import *
|
||||
|
||||
# Get file from args
|
||||
from sys import argv
|
||||
|
||||
try:
|
||||
im = argv[1]
|
||||
n = Thread(target=nn, args=[root, im,])
|
||||
n.start()
|
||||
except:
|
||||
print("None image")
|
||||
|
||||
#######################
|
||||
|
||||
|
||||
def map_up():
|
||||
global canvas_old, canvas, label
|
||||
|
||||
while True:
|
||||
# Prepare image for tkiner
|
||||
@ -53,15 +72,15 @@ def image_up():
|
||||
# Update
|
||||
root.update()
|
||||
sleep(2)
|
||||
# Remove ols
|
||||
# Remove old
|
||||
canvas_old.destroy()
|
||||
except:
|
||||
pass
|
||||
# New canvas now is old
|
||||
canvas_old = canvas
|
||||
|
||||
image = Thread(target=image_up)
|
||||
image.start()
|
||||
map = Thread(target=map_up)
|
||||
map.start()
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user